- [C#] Viết ứng dụng xem và dò kết quả xổ số kiến thiết miền nam
- [EBOOK] Chia sẽ giáo trình học lập trình C - Giáo sư Phạm Văn Ất
- [C#] Hướng dẫn viết ứng dụng theo dõi máy in bao nhiêu trang (Monitor Printer)
- [C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
- [C#] Chia sẽ class Install, Uninstall, Start và Stop Services Winform
- [C#] Tìm kiếm tập tin file nhanh chóng trên Winform sử dụng thư viện FastSearchLibrary
- [C#] Giới thiệu thư viện Fluent FTP Awesome dùng để làm việc với FTP
- [C#] Sử dụng thư viện Mini Profiler Integrations ghi log thực hiện các câu lệnh SQL
- [DEVEXPRESS] Thiết kế Dropdown ButtonBarItem trên Form Ribbon
- [C#] Lưu trạng thái các control trên Winform vào Registry Windows
- [C#] Ứng dụng ví dụ Simple Observer Pattern tăng giảm số lượng trên winform
- [C#] Hướng dẫn lấy thời gian thực server time trên winform
- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
[DEVEXPRESS] Hướng dẫn bỏ phím chức năng Watermark và Export excel, pdf ra khỏi Dialog print report C#
Bài viết hôm nay, mình sẽ hướng dẫn các bạn cách loại bỏ các button chức năng trong Print Report Dialog của Devexpress.
Nếu bạn nào đã và đang làm việc với report Devexpress, thì Devexpress có hỗ trợ cho chúng ta các chức năng:
VD: Thêm WaterMark, Export File PDF, Excel, Rtf, Html...
Ví dụ: Các bạn thiết kế một report in đơn hàng vật tư, report các bạn hiển thị thông tin chưa phê duyệt thì có watermark trên report, cho người dùng không thể in ra.
Nhưng trên Report dialog lại có tính năng watermark, vậy chúng ta phải button này ra, để cho người dùng ko chỉnh sửa được.
Hoặc mình có thể khóa các chức năng, export file ra pdf, excel,... không có phép người dùng xuất dữ liệu trên report ra excel, rtf, html...
Source code C#:
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
private void button1_Click(object sender, System.EventArgs e) {
// Create a Print Tool with an assigned report instance.
ReportPrintTool printTool = new ReportPrintTool(new XtraReport1());
// Access the Print Tool's Printing System.
PrintingSystemBase printingSystem = printTool.PrintingSystem;
// Remove the Watermark command from the Print Preview UI.
if (printingSystem.GetCommandVisibility(PrintingSystemCommand.Watermark)
!= CommandVisibility.None) {
printingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark,
CommandVisibility.None);
}
// Enable the Document Map command in the Print Preview UI.
printingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap,
CommandVisibility.All);
// Disable document export to any format.
printingSystem.SetCommandVisibility(new PrintingSystemCommand[] {
PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportDocx,
PrintingSystemCommand.ExportHtm, PrintingSystemCommand.ExportMht, PrintingSystemCommand.ExportPdf,
PrintingSystemCommand.ExportRtf, PrintingSystemCommand.ExportXls, PrintingSystemCommand.ExportXlsx,
PrintingSystemCommand.ExportGraphic },
CommandVisibility.None);
// Enable the "Export to CSV" and "Export to TXT" commands.
printingSystem.SetCommandVisibility(new PrintingSystemCommand[] {
PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt },
CommandVisibility.All);
// Disable export and mailing of documents.
printingSystem.SetCommandVisibility(new PrintingSystemCommand[] {
PrintingSystemCommand.SendFile },
CommandVisibility.None);
// Show the report's Print Preview in a dialog window.
printTool.ShowPreviewDialog();
}
HAVE FUN :)