PrintPreviewDialog


The PrintPreviewDialog component displays a dialog box that shows what a print document will look like when it is printed. You can use this component to display a print preview dialog similar to the one shown in Figure G-19. This dialog box contains a PrintPreviewControl, plus some extra tools to let the user control the preview.

image from book
Figure G-19: The PrintPreviewDialog component lets you easily display a full-featured print preview dialog box.

The tools that run from left to right across the top of the dialog box automatically give the user the following features:

  • A Print button that prints the document

  • A Zoom menu that lets the user zoom to scales between 10% and 500%, or to select Auto zoom

  • Buttons that make the dialog box display one, two, three, four, or six pages at a time

  • A button that closes the dialog box

  • A text box and numeric up/down control that let the user select the number of the page to display

The dialog box’s most important property is Document. This property determines the PrintDocument object that the dialog box previews. See the section “PrintDocument” earlier in this appendix for more information about this class.

The component’s most important methods are Show, which displays the dialog box, and ShowDialog, which displays the dialog box modally.

Using this component is remarkably simple. Set its Document property and catch the PrintDocument object’s PrintPage event as shown in the previous section. Then display the dialog box as in the following code:

  dlgPrintPreview.ShowDialog() 

The rest is automatic. The dialog box lets the user move through the document’s pages, zoom in and out, and even print the document.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net