简体   繁体   中英

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.

Is there a way to do that through code?

Call PrintToPrinter on the report.

Prints the specified pages of the report to the printer selected using the PrintOptions.PrinterName property. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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