locked
Reportviewer PrintDialog Cancel Botton RRS feed

  • Question

  • Hi,

     Is it posible to know when the user clicked the cancel button in the printdialog of a reportviewer?

    I need something like this:

    Private Sub ReportViewer1_Print(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ReportViewer1.Print

    Me.ReportViewer1.PrintDialog()

    ' If the user clicks on cancel in the printdialog Then Exit Sub

    Call ActualizarContraRecibo()

    Me.VwContraRecibosTableAdapter.Fill(ConsultasSqlDataSet.vwContraRecibos)

    End Sub

    Thanks for your help.

    Sorry for my english is not good.

    Wednesday, July 26, 2006 9:11 PM

Answers

  • You could hide the built in print button and add your own button to the form to launch your own print dialog and perform the printing yourself.  The PrintDialog method wraps the built in PrintDialog class and makes a call to ServerReport.Render() or LocalReport.Render() with the "IMAGE" renderer.  You would need to supply device info for the EMF format and appropriate page margins/size.  It's not a lot of code and there are samples in MSDN that deal with invoking the print dialog.  There is also a sample on www.gotreportviewer.com that shows how to print from a console application, to demonstrate the necessary calls on the ReportViewer side.

    The only thing you really lose by printing yourself is that the ReportViewer will cache the EMF streams from print preview mode and use them again for printing if the page margins and paper size are the same.

    Saturday, August 12, 2006 2:28 AM

All replies

  • There is no way to determine this currently.  But this would be useful information to return and I will look into adding this in the future.
    Tuesday, August 1, 2006 1:55 AM
  • Thank you,

    The thing is that im using reportviewer to print checks (for bills to pay). Currently I have to make the changes in the DataBase when the user clicks the print botton in the reportviewer. But if the user clicks cancel on the printdialog, then the changes in the DB shouldnt have been applied. If there's a way to know if the report did print, then I would put the code for the BD changes after knowing the report did print.

    PS. Sorry for my english, is not my primary language.

    Blessings

    Friday, August 11, 2006 10:49 PM
  • You could hide the built in print button and add your own button to the form to launch your own print dialog and perform the printing yourself.  The PrintDialog method wraps the built in PrintDialog class and makes a call to ServerReport.Render() or LocalReport.Render() with the "IMAGE" renderer.  You would need to supply device info for the EMF format and appropriate page margins/size.  It's not a lot of code and there are samples in MSDN that deal with invoking the print dialog.  There is also a sample on www.gotreportviewer.com that shows how to print from a console application, to demonstrate the necessary calls on the ReportViewer side.

    The only thing you really lose by printing yourself is that the ReportViewer will cache the EMF streams from print preview mode and use them again for printing if the page margins and paper size are the same.

    Saturday, August 12, 2006 2:28 AM
  • How can I invoke the report viewer

    activex print dialog? In javascript or code behind...

     

    I am creating a customize toolbar of the reportviewer and I am using serverreport.

     

    Thanks

    Friday, November 16, 2007 5:32 AM
  • Update:

    The solution I found for invoking the activex print dialog is to call LoadPrintControl() of the RSToolbar object in the javascript.

     

    How this help someone...

    Monday, November 19, 2007 4:54 AM
  •  

    This was very upsetting. Most dialogs return a result and we really need this one. Definitely push for this to be released. It would be nice to set how many copies it will print and to be able to hide or disable that feature of the Dialog.... and maybe even return back a successful print job for that matter or just if the user pressed ok or cancel would be great. I was in the same situation and now I have to go code around passing in junk to a normal print dialog and setting the control up. They must have had trouble with the class passing back a DialogResult or something. Disappointing if you ask me.
    Friday, December 14, 2007 7:29 PM
  • Is this fixed now? Is there a way to return the status if Cancel is clicked on the print dialog? I need this functionality ASAP.
    Regards
    Partha Mandayam
    IT Consultant
    Invacare
    http://weblogs.asp.net/pmandayam
    http://partha.tripod.com
    Monday, April 11, 2011 7:12 PM
  • I looked at the sample and don't see PrintDialog being called. Can you give some sample code that calls the Printdialog and traps the Cancel button?
    Regards
    Partha Mandayam
    IT Consultant
    Invacare
    http://weblogs.asp.net/pmandayam
    http://partha.tripod.com
    Monday, April 11, 2011 7:13 PM