0

I have encountered this problem a lot of times on the internet, but didn't find a good way to fix this.

What I want is to print a report from the ReportViewer control, and if it has been printed, I need to change some stuff in the database (like the user that printed, what time the reports has been printed).

Now I used the reportViewer.PrintDialog() method (which prints fine) but I can't figure out a way to learn if the user actually printed the document, or cancelled the PrintDialog box.

I also tried the System.Windows.Controls.PrintDialog() which does return a DialogResult, but I couldn't find a way to set the reportViewer's report as the PrintDocument's source.

Has anyone of you found a way to do it?

Thanks in advance, and more info/code can be provided if asked.

Jelle Capenberghs
  • 794
  • 2
  • 14
  • 30
  • If you mean physically printed out, then there's no sensible way to do it. Nearest thing I've seen is to request the print with some sort of job bar code on it, and then confirm production of the print by scanning said bar code in. – Tony Hopkinson Mar 13 '12 at 15:49
  • I just meant if the user clicked the "Print" button or the "Cancel" button in the PrintDialog, the title is indeed a little misleading, i'll change it. – Jelle Capenberghs Mar 13 '12 at 15:50

2 Answers2

2

In VB.NET, try the following:

If reportViewer.PrintDialog() = Windows.Forms.DialogResult.OK Then
 'Put your stuff here
End If
Nat Ritmeyer
  • 5,634
  • 8
  • 45
  • 58
omar
  • 21
  • 2
2

Oh

If it's C#

Dialog boxes return a value of type DialogResult

so something like

if (System.Windows.Controls.PrintDialog().ShowDialog() == DialogResult.OK)
{
// Mark item as Prionted by User U
}
Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39