2

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

myreport.PrintDialog()

如果我在 Windows 上单击“中止”,PrintDialog则报告将在标准打印机上打印。我该如何处理这种中止?我只想在 OK 上打印,但我无法处理DialogResult.

4

2 回答 2

1

你有过这样的工作吗?

PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
    // do your printing process here
}
于 2012-12-19T12:56:50.327 回答
0

PrintTool.PrintDialog()方法;

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

Return value
Type: Nullable<Boolean> 
true if the user clicks OK in the dialog box; false if the user clicks Cancel;

How to: Print a Report

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");
}
于 2012-12-19T13:03:08.677 回答