Giving user ability to cancel a print job.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a PrintPreviewDialog to show a document. Via the BeginPrint
event, I open a PrintDialog to let the user choose what pages (and other
settings) to print. However, I can't find a way to allow the user to cancel
the print command if the 'Cancel' button is pressed from the PrintDialog.

I tried throwing an exception, but it is only caught when I run in debug
mode (bug in C#?). i.e. If I 'Start without debugging', then the exception I
throw is not caught. But if I 'Start with debugging', even without stepping
through the code, the exception is caught.

Anyway, any suggestions on cancelling a print job once the
PrintDocument.Print command is started?

Thanks,
--Michael
 
Well folks... It seems that all I had to do was read a little deeper.

For those of you who are interested, I found that the BeginPrint event
method has a parameter 'PrintEventArgs e'. Set e.Cancel to true and the
print job is cancelled.

However, if anyone has any input on the dillemma with the exception that is
only caught while Started with the debugger, I would love to hear it.

Thanks,
--Michael
 
Back
Top