NEWS

[DEVEXPRESS] Hướng dẫn bỏ phím chức năng Watermark và Export excel, pdf ra khỏi Dialog print report C#

[DEVEXPRESS] Hướng dẫn bỏ phím chức năng Watermark  và Export excel, pdf ra khỏi Dialog print report C#
Đăng bởi: Thảo Meo - Lượt xem: 7408 09:20:24, 09/07/2018C#   In bài viết

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:

report devexpress

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.

 

report devexpress 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 :)

Tags: report

THÔNG TIN TÁC GIẢ

BÀI VIẾT LIÊN QUAN

[DEVEXPRESS] Hướng dẫn bỏ phím chức năng Watermark  và Export excel, pdf ra khỏi Dialog print report C#
Đăng bởi: Thảo Meo - Lượt xem: 7408 09:20:24, 09/07/2018C#   In bài viết

CÁC BÀI CÙNG CHỦ ĐỀ

Đọc tiếp
.