PageSetupDialog


The PageSetupDialog component displays a dialog box that lets the user specify properties for printed pages. For example, the user can specify the printer’s paper tray, page size, margins, and orientation (portrait or landscape). Figure G-16 shows the dialog box in action.

Before you can display the dialog box, you must assign it a PageSetting object to modify. You can do this in two ways. First, you can set the component’s Document property to a PrintDocument object. If the user clicks OK, then the dialog box modifies the PrintDocument’s settings. This method is preferred because a PrintDocument object defines both page settings and printer settings.

Second, you can set the dialog box’s PageSettings property to a PageSettings object. If the user clicks OK, then the dialog modifies that object’s settings.

image from book
Figure G-16: The PageSetupDialog component lets the user specify printing settings.

Your program calls the component’s ShowDialog method to display the dialog. ShowDialog returns DialogResult.OK if the user makes setting and clicks OK. It returns DialogResult.Cancel if the user cancels. Often, the program doesn’t need to know whether the user accepted or canceled the dialog box, however, because the dialog box modifies a PageSettings object. The program can use that object when printing later, so it doesn’t need to keep track of whether the user accepted or canceled the dialog box.

The following code displays a PageSetupDialog attached to a PrintDocument object:

  PageSetupDialog1.Document = New PrintDocument PageSetupDialog1.ShowDialog() 

The following table describes the PageSetupDialog component’s most useful properties.

Open table as spreadsheet

Property

Purpose

AllowMargins

Determines whether the dialog box lets the user modify its margin settings.

AllowOrientation

Determines whether the dialog box lets the user modify its orientation settings.

AllowPaper

Determines whether the dialog box lets the user modify its paper settings.

AllowPrinter

Determines whether the dialog box lets the user modify its printer settings.

Document

The PrinterDocument object that the dialog box will modify.

MinMargins

Gives the smallest allowed margin values. MinMargins is a reference to a Margins object that has Left, Right, Top, and Bottom properties that you can use to specify each margin separately.

PageSettings

The PageSettings object that the dialog box will modify.

PrinterSettings

The PrinterSettings object that the dialog box will modify when the user clicks the Printer button. If you set the Document property, then the PrinterDocument object includes a PrinterSettings object.

ShowHelp

Determines whether the dialog box displays a Help button. If you set this to True, then the application should catch the dialog box’s HelpRequest event and give the user some help.

ShowNetwork

Determines whether the dialog box displays a Network button on the Printer setup dialog box when the user clicks the Printer button.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net