在脚本引用中添加
DevExpress.XtraPrinting.v18.1.dll
DevExpress.Utils.v18.1.dll
XtraReport 通过 PrintingSystemBase 基类进行打印,在打印前记录当前 XtraReport ,在打印文件发送到打印机后(EndPrint事件),关闭预览界面。
XtraReport report;
private void PrintObject_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
report = (sender as XtraReport);
report.PrintingSystem.EndPrint += PrintingSystem_EndPrint;
}
private void PrintingSystem_EndPrint(object sender, EventArgs e) {
report.ClosePreview();
}