当我调用show print preview时如何禁用或隐藏某些按钮? 我想在打印预览中隐藏或禁用电子邮件,或打开或保存(任何按钮)
我将打印预览称为
private void button15_Click(object sender, EventArgs e)
{
gridView1.ShowPrintPreview();
}
有隐藏或禁用它的代码吗?或者我应该为打印本身添加一个控制器? 我使用devexpress
答案 0 :(得分:0)
this(或带有“Ribbon”的版本)会满足您的需求吗?我认为你需要以不同的方式去做:
gridView1.ShowPrintPreview();
尝试设置DocumentViewer的文档来源,如here所示。希望它能与网格数据一起使用。
答案 1 :(得分:0)
您可以通过自定义GridView的打印设置来完成此操作。要执行此操作BaseView.PrintInitialize事件已处理,您可以在其中获得与gridview关联的PrintingSystem。
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");
return;
}
// Open the Preview window.
gridControl1.ShowPrintPreview();
}
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);
}
禁用这些命令后,“SendTo”按钮被禁用。
请参阅:
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
希望这有帮助..