- [C#] Di chuyển và thay đổi kích thước Control Winform khi ứng dụng đang chạy
- [VB.NET] Chia sẻ source tạo sắp xếp đội hình bóng đá Line-ups đội bóng
- [C#] Hướng dẫn chỉnh sửa Text của label trực tiếp trên winform
- [C#] Hướng dẫn custom TextBox giống Ultraviewer trên Winform
- [C#] Show Modal Winform like Bootstrap
- [DATABASE] Thứ tự thực hiện mệnh đề truy vấn SELECT trong Sqlserver
- [C#] Hướng dẫn viết addin Excel Lấy hình ảnh từ URL internet vào Excel
- [DATABASE] TSQL view max length all column data trên table Sqlserver
- [DEVEXPRESS] Hướng dẫn sử dụng MailMerge kèm Hình ảnh trên Winform
- [DATABASE] Hướng dẫn truy vấn xem kích thước lưu trữ của từng bảng ghi Table trên sqlserver
- [C#] Hướng dẫn Fake Date Time sử dụng thư viện Harmony
- [DATABASE] Phân biệt câu lệnh DDL và DML trong sqlserver
- [C#] Hướng dẫn convert file mã HTML sang file Pdf trên winform
- [DEVEXPRESS] Tạo các loại mã vạch Barcode trực tiếp trên Devexpress Barcode API
- [DEVEXPRESS] Hướng dẫn custom Simple button thành Progressbar
- [DATABASE] Tách số và chữ từ chuỗi - hàm tối ưu hóa tách số và chữ trong Sqlserver
- [C#] Tìm kiếm gần đúng Full Text Search sử dụng thư viện Lucene.NET
- [C#] Chia sẻ tài liệu, sdk và source code máy chấm công dòng máy ZKTeco
- [C#] Memory Cache là gì, và sử dụng trong ứng dụng Winform
- [DATABASE] Khóa chính Primary Key trong Sqlserver
[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 :)