Print Preview

 

This sample application is an extension of the previous example that demonstrated how to generate as basic plain-text report using the PrintDocument object. In that previous example, when the "Print Customer List" button was clicked, the output went directly to the printer. In this expanded example, the PrintPreviewDialog control is added, which enables us to provide the option to do a print preview of the output, from which the user can choose whether or not they want to print to the printer.

 

When designing the application, a PrintPreviewDialog control was added from the "Printing" section of the Toolbox. Note that since the PrintPreviewDialog control is a non-visual control, when you double-click it in the Toolbox, it is not placed directly on the form, but in the gray workspace area below the form. Note also that a Group Box containing two Radio Buttons was added to on the form to provide the user with the choice to print directly to the printer or to generate a print preview, with print preview being set as the default:

 

 

 

When the program is run and the user clicks the Print Customer List button with Print Preview radio button checked, the print preview is displayed. The print preview dialog control provides a toolbar at the top with the built-in functionality to print, zoom, navigate to different pages, etc.

 

 

 

Download the project files for this sample application here.