如何禁用或隐藏显示打印预览中的某些按钮?
how to disable or hide certain button in show print preview?
如何在调用显示打印预览时禁用或隐藏某些按钮?
我想在打印预览中隐藏或禁用 emailto,或打开或保存(任何按钮)
我将打印预览称为
private void button15_Click(object sender, EventArgs e)
{
gridView1.ShowPrintPreview();
}
是否有隐藏或禁用它的代码?或者我应该为打印本身添加一个控制器吗?
我正在使用 devexpress
this(或带有 "Ribbon" 的版本)是否适合您的需要?我认为您需要以不同于调用的方式进行操作:
gridView1.ShowPrintPreview();
尝试设置 DocumentViewer 的文档源,如图所示 here。希望它能与网格数据一起使用。
您可以通过自定义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
希望对您有所帮助..
如何在调用显示打印预览时禁用或隐藏某些按钮?
我想在打印预览中隐藏或禁用 emailto,或打开或保存(任何按钮)
我将打印预览称为
private void button15_Click(object sender, EventArgs e)
{
gridView1.ShowPrintPreview();
}
是否有隐藏或禁用它的代码?或者我应该为打印本身添加一个控制器吗? 我正在使用 devexpress
this(或带有 "Ribbon" 的版本)是否适合您的需要?我认为您需要以不同于调用的方式进行操作:
gridView1.ShowPrintPreview();
尝试设置 DocumentViewer 的文档源,如图所示 here。希望它能与网格数据一起使用。
您可以通过自定义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
希望对您有所帮助..