简体   繁体   English

Crystal Report Viewer以编程方式打印到默认打印机

[英]Crystal Report Viewer Print to Default Printer Programmatically

I have a Crystal Report that I've imported into the form, and I want it so that when I double click on something, it will load the report, and then print it. 我有一个Crystal报表,我已经导入到表单中,我想要它,这样当我双击某个东西时,它会加载报表,然后打印它。

Is there a way to do that through code? 有没有办法通过代码来做到这一点?

Call PrintToPrinter on the report. 在报告上调用PrintToPrinter

Prints the specified pages of the report to the printer selected using the PrintOptions.PrinterName property. 将报告的指定页面打印到使用PrintOptions.PrinterName属性选择的打印机。 If no printer is selected, the default printer specified in the report will be used. 如果未选择打印机,则将使用报告中指定的默认打印机。

Something like this: 像这样的东西:

using (var report = new YourCrystalReport())
{
    // Call report.SetDataSource() if necessary
    // Call report.SetParameterValue() as necessary

    report.PrintToPrinter(...);
}

Although the doc I linked says VS2003, I just tried it in VS2012 using the latest crystal driver, and the call appears to be the same. 虽然我链接的文件说VS2003,我只是在VS2012中使用最新的水晶驱动程序尝试了它,并且呼叫看起来是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM