How to capture the printe event on the ReportViewer?

4 posts, 0 answers
  1. Volkan
    Volkan avatar
    5 posts
    Member since:
    Jun 2011

    Posted 08 Feb 2012 Link to this post

    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

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Feb 2012 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Volkan
    Volkan avatar
    5 posts
    Member since:
    Jun 2011

    Posted 08 Feb 2012 Link to this post

    Strange... it works now (!?!?!?)

    Thank you Richard
    Volkan
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Feb 2012 Link to this post

    you're welcome. Please remember to mark as answer in case others have the same issue
    Thanks
Back to Top