This is a migrated thread and some comments may be shown as answers.

WPF printdialog result

3 Answers 404 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Koen
Top achievements
Rank 1
Koen asked on 21 Mar 2013, 09:38 PM
Hi All,

I'm using Telerik's ReportViewer in a WPF app to show some reports.
The PrintReportCommand on the ReportViewerModel nicely shows the standard print dialog for printing.

This is the behavior I'm looking for, however, I need to know the result of this standard print dialog.
Is there any way to get to that?

I've already tried:
  • To get the result by manually calling "reportProcessor.PrintReport(this.ReportSource, null);" 
    As the documentation states, this also shows the standard print dialog, but again, I found no way of accessing the dialog result.
  • To find any event on ReportProcessor or InstanceReportSource indicating that the report was printed
     


Thanks for any help.
Regards,
Koen

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 26 Mar 2013, 02:56 PM
Hi Koen,

Please elaborate further on your requirements. What do you mean by "to know the result of this standard print dialog"?

Generally the WPF report viewer and ReportProcessor.PrintReport are is using the standard .NET printing capabilities. You may find useful the PrintDocument.Print Method.

Greetings,
Peter
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

0
Koen
Top achievements
Rank 1
answered on 26 Mar 2013, 03:00 PM
The ReportProcessor.PrintReport method shows the standard print dialog (The one where you choose your printer etc.).
This dialog has an OK and a Cancel button. I'd like to know which of the buttons the user pressed.


Regards,
Koen
0
Chavdar
Telerik team
answered on 29 Mar 2013, 12:57 PM
Hello,

There is no way to understand which button has been clicked when the ReportProcessor shows the PrintDialog  - the report document is just not printed if Cancel has been chosen. However, you can display the PrintDialog on your own and pass the PrinterSettings returned by it to the ReportProcessor.PrintReport method. When the second parameter of PrintReport method is not null and the printer settings are valid, the ReportProcessor will not show the PrintDialog. To test, you can try with the following code snippet:

using (var printDialog = new System.Windows.Forms.PrintDialog())
{
    if (DialogResult.OK == printDialog.ShowDialog())
    {
        var reportProcessor = new ReportProcessor();
        var irs = new InstanceReportSource();
        irs.ReportDocument = new BarcodesReport();
        reportProcessor.PrintReport(irs, printDialog.PrinterSettings);
    }
}

Hope this helps.

Regards,
Chavdar
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

Tags
General Discussions
Asked by
Koen
Top achievements
Rank 1
Answers by
Peter
Telerik team
Koen
Top achievements
Rank 1
Chavdar
Telerik team
Share this question
or