![]() ![]() | ||
Page setup dialogs let the user specify the format for the pages that are to be printed, such as setting page orientation (portrait or landscape), margin size, and so on. You can use a Page Setup dialog to modify both the PrinterSettings and PageSettings objects in a PrintDocument object to record the settings the user wants to use for printing.
We've already seen the PrinterSettings class (see Tables 9.24, 9.25, and 9.26)—objects of this class can hold the page range to print, the number of copies to print, the printer to use and so on—but we haven't seen the PageSettings class yet. Here are the notable properties of this class:
Bounds— Gets the bounds of the page.
Color— Gets/sets a value indicating whether the page should be printed in color.
Landscape— Gets/sets a value indicating whether the page is printed in landscape or portrait orientation.
Margins— Gets/sets the margins for this page.
PaperSize— Gets/sets the paper size for the page.
PaperSource— Gets/sets the page's paper source.
PrinterResolution— Gets/sets the printer resolution for the page.
PrinterSettings— Gets/sets the printer settings associated with the page.
Here's how I let the user display a Page Setup dialog in the Printing example on the CD-ROM, and record the new settings in that example's PrintDocument object:
Private Sub MenuItem2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MenuItem2.Click PageSetupDialog1.Document = PrintDocument1 PageSetupDialog1.PrinterSettings = PrintDocument1.PrinterSettings PageSetupDialog1.PageSettings = PrintDocument1.DefaultPageSettings If PageSetupDialog1.ShowDialog = DialogResult.OK Then PrintDocument1.PrinterSettings = PageSetupDialog1.PrinterSettings PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings End If End Sub
You can see the page setup dialog in the Printing example in Figure 9.10.
![]() ![]() | ||