Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';“打印时中止”对话框时不响应_C#_Devexpress_Report - Fatal编程技术网

C# Can';“打印时中止”对话框时不响应

C# Can';“打印时中止”对话框时不响应,c#,devexpress,report,C#,Devexpress,Report,我有一份报告,想打印出来。目前我正在使用: myreport.PrintDialog() 如果我在WindowsPrintDialog上单击“中止”,报告将在标准打印机上打印。 我如何处理这个中止? 我只想在OK上打印,但我无法处理对话框result您是这样工作的吗 PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == DialogResult.OK) { // do your printing proce

我有一份报告,想打印出来。目前我正在使用:

myreport.PrintDialog()
如果我在Windows
PrintDialog
上单击“中止”,报告将在标准打印机上打印。 我如何处理这个中止?
我只想在OK上打印,但我无法处理
对话框result

您是这样工作的吗

PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
    // do your printing process here
}
从方法上

运行用于选择打印机的打印对话框,设置一些 打印选项和打印文档


这段代码恰好重新创建了OP的问题。它将忽略PrintDialog()的返回值。
Return value
Type: Nullable<Boolean> 
true if the user clicks OK in the dialog box; false if the user clicks Cancel;
using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...

private void button1_Click(object sender, EventArgs e) {
    // Create a report instance, assigned to a Print Tool.
    ReportPrintTool pt = new ReportPrintTool(new XtraReport1());

    // Invoke the Print dialog.
    pt.PrintDialog();

    // Send the report to the default printer.
    pt.Print();

    // Send the report to the specified printer.
    pt.Print("myPrinter");
}