The Print PreviewDialog Component

The PrintPreviewDialog component is a self-contained dialog box that allows you to preview a print document. It does so by calling the Print method of the PrintDocument component that is specified in the component's Document property and redirecting the output to a graphical representation of the page contained in the dialog box. The PrintDocumentDialog component is shown at run time in Figure 10-3.

Figure 10-3 The PrintDocumentDialog component at run time

The dialog box allows the user to view each page before printing, adjust the number of pages displayed, and adjust the zoom factor so that pages can be viewed close up or at a distance. After viewing the preview, the user can choose to print the document by clicking the Print button, which calls the Print method of the PrintDocument component and directs the output to the printer. The following code example demonstrates how to associate a PrintDocument component with a PrintPreviewDialog component and display it to the user at run time:

PrintPreviewDialog1.Document = PrintDocument1 Pri ntPreviewDialog1. ShowDialogO

printPreviewDialogl.Document = printDocumentl; printPreviewDial ogl. ShowDialogO;

Was this article helpful?

0 0

Post a comment