471,603 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

Giving user ability to cancel a print job.

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
Dec 28 '05 #1
1 3444
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

"Michael R" wrote:
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

Dec 28 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by xscully | last post: by
9 posts views Thread by Rhino | last post: by
2 posts views Thread by eclectic.01 | last post: by
7 posts views Thread by Terry Carroll | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.