PrintDialog Component in VB.NET

The Windows Forms PrintDialog component is a pre-configured dialog box used to select a printer, choose the pages to print, and determine other print-related settings in Windows applications.
  • 3757
Introduction
 
The Windows Forms PrintDialog component is a pre-configured dialog box used to select a printer, choose the pages to print, and determine other print-related settings in Windows applications. Use it as a simple solution for printer and print-related settings selection in lieu of configuring your own dialog box. You can enable users to print many parts of their documents: print all, print a selected page range, or print a selection. By relying on standard Windows dialog boxes, you create applications whose basic functionality is immediately familiar to users. The PrintDialog component inherits from the CommonDialog class.

Use the ShowDialog method to display the dialog at run time. This component has properties that relate to either a single print job (PrintDocument class) or the settings of an individual printer (PrinterSettings class). Either of these, in turn, may be shared by multiple printers.

When it is added to a form, the PrintDialog component appears in the tray at the bottom of the Windows Forms Designer.

Displaying the PrintDialog Component
 
The PrintDialog component is the standard Windows print dialog box that many of your users will be familiar with. Since your users will be immediately comfortable with it, it would be beneficial for you to use the PrintDialog component.

To display the PrintDialog component

  • Call the ShowDialog method from within the code of your application.

    Once the component is shown, users will interact with it, setting the properties of the print job. These are saved in the PrinterSettings class (and the PageSettings class, if the user accesses the PageSetupDialog through the PrintDialog component) associated with that print job. You can then make calls to the properties they set to determine the specifics of the print job.

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.