David ChopperField David ChopperField - 7 months ago 53
C# Question

how to disable or hide certain button in show print preview?

how to disable or hide certain button when i call show print preview ?
i want to hide or disable emailto, or open, or save (any button) in print preview
print preview

i call the print preview like

private void button15_Click(object sender, EventArgs e)

is there any code to hide or disable it? or should i add a controller for the print itself ?
iam using devexpress


You can do it by customizing the print settings of the GridView. To do this BaseView.PrintInitialize event is handled and there you are able to get the PrintingSystem associated with the gridview.

private void btnPrintPreview_Click(object sender, EventArgs e)
    // Check whether the GridControl can be previewed.
    if (!gridControl1.IsPrintingAvailable)
        MessageBox.Show("The 'DevExpress.XtraPrinting' library is not found", "Error");

    // Open the Preview window.

private void gridView1_PrintInitialize(object sender, DevExpress.XtraGrid.Views.Base.PrintInitializeEventArgs e)
    PrintingSystemBase pb = e.PrintingSystem as PrintingSystemBase;            
    pb.SetCommandVisibility(PrintingSystemCommand.SendPdf, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendTxt, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendRtf, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendXls, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendMht, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendXlsx, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendCsv, CommandVisibility.None);
    pb.SetCommandVisibility(PrintingSystemCommand.SendGraphic, CommandVisibility.None);

After disabling these command "SendTo" button get disabled.

Refer these:
How to: Customize Print Settings When Printing GridControl
Hide the tools in the print preview ribbon control
How to hide toolbar buttons in the Print Preview
Disable or Remove a Button from Ribbon Preview Control

Hope this help..