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

How to capture the printe event on the ReportViewer?

3 Answers 522 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Volkan
Top achievements
Rank 1
Volkan asked on 08 Feb 2012, 02:50 PM
Hi, i have here a winform that uses the Telerik.ReportViewer.WinForms.ReportViewer() control to print some letters.

I need a solution to log the print action in a database, i have add a print event, but its not captured :(

here the code:

private void testPrint()
{
 Telerik.ReportViewer.WinForms.ReportViewer viewer = new Telerik.ReportViewer.WinForms.ReportViewer();
 viewer.Print += new System.ComponentModel.CancelEventHandler(this.viewer_Print);
 Report_Password report = new Report_Password();
 viewer.ShowExportButton = false;
 viewer.ShowHistoryButtons = false;
 viewer.ShowPageNavigationControls = false;
 viewer.ShowPageSetupButton = false;
 viewer.ShowParametersButton = false;
 viewer.ShowStopButton = false;
 viewer.ShowZoom = false;
 viewer.ShowRefreshButton = false;
 viewer.ZoomMode = Telerik.ReportViewer.WinForms.ZoomMode.FullPage;
 viewer.Dock = DockStyle.Fill;
 viewer.Report = report;
}

 void viewer_Print(object sender, CancelEventArgs e)
{
 // Not caputred here :(
// Log to DB
}

how can i capture this?

Thank you
Volkan

3 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 08 Feb 2012, 03:39 PM
Hello,

I've just tried this in a new project with a blank report, and the print button event can be captured without a problem in the latest release.

The code I used was as follows:
private void RadForm1_Load(object sender, EventArgs e)
{
    this.reportViewer1.Print += new CancelEventHandler(reportViewer1_Print);
}
 
void reportViewer1_Print(object sender, CancelEventArgs e)
{
    MessageBox.Show("Printing");
}

Please can you try this and let me know if it works. If this is ok, please remember to mark as answer. If you need further help, then just let me know
Thanks
Richard
0
Volkan
Top achievements
Rank 1
answered on 08 Feb 2012, 03:59 PM
Strange... it works now (!?!?!?)

Thank you Richard
Volkan
0
Richard Slade
Top achievements
Rank 2
answered on 08 Feb 2012, 04:12 PM
you're welcome. Please remember to mark as answer in case others have the same issue
Thanks
Tags
General Discussions
Asked by
Volkan
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Volkan
Top achievements
Rank 1
Share this question
or