The Page SetupDialog Component

The PageSetupDialog component enables users to select options about the setup of the pages for a print job. A PageSetupDialog component at run time is shown in Figure 10-2.

Figure 10-2 The PageSetupDialog component at run time

Changes made by the user in the PageSetupDialog are automatically reflected in the PrinterSettings class of the PrintDocument component that is associated with the PageSetupDialog box. You can set the options that will be displayed to the user by setting the properties of the PageSetupDialog component. Important properties of the PageSetupDialog component are shown in Table 10-2.

Table 10-2 Important Properties of the PageSetupDialog Component

Property

Description

AllowMargins

Indicates whether the margins section of the dialog box is enabled.

AllowOrientation

Indicates whether the orientation section of the dialog box (landscape versus portrait) is enabled.

AllowPaper

Indicates whether the paper section of the dialog box (paper source and paper size) is enabled.

AllowPrinter

Indicates whether the printer button is enabled.

Document

The PrintDocument associated with this component.

EnableMetric

Indicates whether the margin settings, when displayed in millimeters, should be automatically converted to and from hundredths of an inch.

MinMargins

Indicates the minimum margins, in hundredths of an inch, the user is allowed to select.

ShowHelp

Indicates whether the Help button is visible.

ShowNetwork

Indicates whether the Network button is visible.

To show a PageSetupDialog, the component must be associated with an instance of the PageSettings class. The preferred way of doing this is to set the Document property to an instance of the PrintDocument class, which automatically sets the PrintDocu-ment.PrinterSettings instance to the PageSetupDialog.PrinterSettings property. The following code example demonstrates how to set the Document property of the PageSetupDialog component and then display it to the user.

' Assumes an instance of PrintDocument named PrintDocument1 and an ' instance of PageSetupDialog named PageSetupDialog1.

PageSetupDialog1.Document = PrintDocument1 PageSetupDialog1.SliowDialogO

// Assumes an instance of PrintDocument named printDocument1 and an // instance of PageSetupDialog named pageSetupDialog1. pageSetupDialog1.Document = printDocument1; pageSetupDialog1.ShowDialog() ;

Was this article helpful?

0 0

Post a comment