0

我正在使用 C# 和 WPF 生成水晶报告。

到目前为止我的代码是

report.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)System.Drawing.Printing.PaperKind.A5;
report.PrintToPrinter(2, true, 0, 0);
crystalReportsViewer1.ViewerCore.ReportSource = report;
crystalReportsViewer1.ToggleSidePanel = SAPBusinessObjects.WPF.Viewer.Constants.SidePanelKind.None;

我需要显示一个对话框,即 PrintDialog 以允许用户选择他想要打印的打印机,其余的打印设置由我在代码中完成。请建议....

4

1 回答 1

0

试试下面的代码

        PrintDialog printDialog1 = new PrintDialog();

        if (printDialog1.ShowDialog() == true)
        {
            report.PrintOptions.PrinterName = printDialog1.PrintQueue.Name;
            report.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)System.Drawing.Printing.PaperKind.A5;
            report.PrintToPrinter(2, true, 0, 0);
            crystalReportsViewer1.ViewerCore.ReportSource = report;
            crystalReportsViewer1.ToggleSidePanel = SAPBusinessObjects.WPF.Viewer.Constants.SidePanelKind.None;
        }

System.Printing 必须在您的引用中,以便您可以使用 PrintQueue.Name。

于 2013-07-15T15:15:10.787 回答