PrintPreviewDialog
-
I have two problems. The more important: how can I know if the user did hit the Print button or just saw the preview and close the window; the best whould be to close the dialog after the user press the Print button and let me know about this (return ... , delegate, event,...) The other: how can I set the zoom? Default the dialog is very small, I managed to increase it's size but the zoom is still less then 100% and the text is not readable; I can not find anything related to zoom
-
I have two problems. The more important: how can I know if the user did hit the Print button or just saw the preview and close the window; the best whould be to close the dialog after the user press the Print button and let me know about this (return ... , delegate, event,...) The other: how can I set the zoom? Default the dialog is very small, I managed to increase it's size but the zoom is still less then 100% and the text is not readable; I can not find anything related to zoom
I got this code a couple of days ago of the discussion boards, it worked for me. foreach (Control c in this.printPreviewDialog1.Controls) { if (c is PrintPreviewControl) { ((PrintPreviewControl)c).Zoom = 0.75; } } Don't know about the print button.
-
I got this code a couple of days ago of the discussion boards, it worked for me. foreach (Control c in this.printPreviewDialog1.Controls) { if (c is PrintPreviewControl) { ((PrintPreviewControl)c).Zoom = 0.75; } } Don't know about the print button.
I'm the one that originally posted that, and you could do the same thing for the print button. Just cycle through the controls (or even using the same code above) and if the control is a
Button
and has the right properties (if you're developing localized applications, don't check theText
property), and add anEventHandler
to theClickEvent
. Honestly, though, the best think you could do is check theDialogResult
returned fromPrintPreviewDialog.ShowDialog
(inherited fromCommonDialog
). If everything is set up correctly in thePrintPreviewDialog
constructor, closing the form with the Close button (the X) should returnDialogResult.Cancel
, while doing anything else should return a different result. Just get the return value and put a breakpoint there to see what's returned. When possible, don't rely on hacks like I mentioned for finding theZoom
property of the hostedPrintPreviewControl
.Microsoft MVP, Visual C# My Articles
-
I'm the one that originally posted that, and you could do the same thing for the print button. Just cycle through the controls (or even using the same code above) and if the control is a
Button
and has the right properties (if you're developing localized applications, don't check theText
property), and add anEventHandler
to theClickEvent
. Honestly, though, the best think you could do is check theDialogResult
returned fromPrintPreviewDialog.ShowDialog
(inherited fromCommonDialog
). If everything is set up correctly in thePrintPreviewDialog
constructor, closing the form with the Close button (the X) should returnDialogResult.Cancel
, while doing anything else should return a different result. Just get the return value and put a breakpoint there to see what's returned. When possible, don't rely on hacks like I mentioned for finding theZoom
property of the hostedPrintPreviewControl
.Microsoft MVP, Visual C# My Articles