Results 1 to 7 of 7

Thread: [2005] - ReportViewer: how to find out if the user has printed

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    21

    [2005] - ReportViewer: how to find out if the user has printed

    Got a bit of a problem with the reportviewer in VB.Net.

    I'm trying to determine if a user has printed a report from the ReportViewer control, so I can write the date/time and username to a database table as part of an audit trail.

    When the user opens a report there is a print button, which calls up a standard print dialog box. However I can't find any way to determine whether the print button has been clicked or not. The reportviewer has a Print event, but this is no good as it's called before the print dialogue is displayed.

    What I ideally need to do is to check the status of the print dialog form to see if the user clicked Print or Cancel. But there seems to be no clear way to do this...

    Any ideas?

  2. #2
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: [2005] - ReportViewer: how to find out if the user has printed

    As the print dialog is a windows standard form, you might need to add the pintdocument or printdialog control (see screenshot attached) to access the events in there.

    Also try here
    http://www.startvbdotnet.com/controls/printdialog.aspx
    Attached Images Attached Images  

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    21

    Re: [2005] - ReportViewer: how to find out if the user has printed

    Ta - I was also looking into that method as well. In order for it to work, you need to assign the Document property of the PrintDialog control (which is your document to be printed).

    This seems straightforward if you're say, printing a PDF document saved somewhere. But I can't see how to pass the generated report in the reportviewer to the PrintDialog document property...

    I could export the report as a PDF first then print it, but I would rather pass the report straight to the PrintDialog control as I may not have access to save the report somewhere.

  4. #4
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: [2005] - ReportViewer: how to find out if the user has printed

    Is there anything in the reportviewer object you can use to automatically map to the PrintDialog control (or set in code).

    I noticed in the Misc properties section you have an expandable section for local and server reports.

    have you tried changing the ProcessMode from Local to Server to see if that makes any difference?

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] - ReportViewer: how to find out if the user has printed

    I don't know how you can catch the click event of the OK button on the print dialog, but you can certainly catch the click event of the print button on the crystalreportviewer control. This button when clicked, all it does is to call crystalreportviewer.PrintReport() method. This PrintReport method will show a print dialog to the user and goes on to print the report if the dialogresult returned from the print dialog = dialogresult.OK.
    So, since we know how it works, we can tap into the ToolStrip of the crystalreportviewer and replace the original print button with one our own. We the handle our own print button.click event. That way, we know exactly when the user clicks the print button. However, do not know if the user actual print the report or not, since we can't get a reference of the print dialog. All we can tell is the user clicked the print button.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  6. #6
    New Member
    Join Date
    Dec 2009
    Posts
    3

    Re: [2005] - ReportViewer: how to find out if the user has printed

    I have the same problem. It can solve?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    21

    Re: [2005] - ReportViewer: how to find out if the user has printed

    Nope - never ever got it to work. I just told the users we couldn't do it and they were happy with that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width