user3169698
user3169698

Reputation: 153

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?

Upvotes: 0

Views: 1759

Answers (1)

Grant Winney
Grant Winney

Reputation: 66449

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.

Upvotes: 2

Related Questions