PageSetupDialog.PageSettings Property

Switch View :
ScriptFree
.NET Framework Class Library
PageSetupDialog.PageSettings Property

Gets or sets a value indicating the page settings to modify.

[Visual Basic]
Public Property PageSettings As PageSettings
[C#]
public PageSettings PageSettings {get; set;}
[C++]
public: __property PageSettings* get_PageSettings();
public: __property void set_PageSettings(PageSettings*);
[JScript]
public function get PageSettings() : PageSettings;
public function set PageSettings(PageSettings);

Property Value

The PageSettings to modify. The default is a null reference (Nothing in Visual Basic).

Example

[Visual Basic, C#] The following code example demonstrates the PageSetupDialog using the PageSettings, PrinterSettings, and ShowNetwork properties. This example assumes it is located in a form containing a button named Button1, a listbox named ListBox1 and a PageSetupDialog named PageSetupDialog1. Ensure the button's click event is connected to the event-handling method in this example.

[Visual Basic] 

    'This method displays a PageSetupDialog object. If the
    ' user clicks OK in the dialog, selected results of
    ' the dialog are displayed in ListBox1.
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click

        ' Initialize the dialog's PrinterSettings property to hold user
        ' defined printer settings.
        PageSetupDialog1.PageSettings = _
            New System.Drawing.Printing.PageSettings

        ' Initialize dialog's PrinterSettings property to hold user
        ' set printer settings.
        PageSetupDialog1.PrinterSettings = _
            New System.Drawing.Printing.PrinterSettings

        'Do not show the network in the printer dialog.
        PageSetupDialog1.ShowNetwork = False

        'Show the dialog storing the result.
        Dim result As DialogResult = PageSetupDialog1.ShowDialog()

        ' If the result is OK, display selected settings in
        ' ListBox1. These values can be used when printing the
        ' document.
        If (result = DialogResult.OK) Then
            Dim results() As Object = New Object() _
                {PageSetupDialog1.PageSettings.Margins, _
                 PageSetupDialog1.PageSettings.PaperSize, _
                 PageSetupDialog1.PageSettings.Landscape, _
                 PageSetupDialog1.PrinterSettings.PrinterName, _
                 PageSetupDialog1.PrinterSettings.PrintRange}
            ListBox1.Items.AddRange(results)
        End If
    End Sub

[C#] 

    //This method displays a PageSetupDialog object. If the
    // user clicks OK in the dialog, selected results of
    // the dialog are displayed in ListBox1.
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {

        // Initialize the dialog's PrinterSettings property to hold user
        // defined printer settings.
        PageSetupDialog1.PageSettings = 
            new System.Drawing.Printing.PageSettings();

        // Initialize dialog's PrinterSettings property to hold user
        // set printer settings.
        PageSetupDialog1.PrinterSettings = 
            new System.Drawing.Printing.PrinterSettings();

        //Do not show the network in the printer dialog.
        PageSetupDialog1.ShowNetwork = false;

        //Show the dialog storing the result.
        DialogResult result = PageSetupDialog1.ShowDialog();

        // If the result is OK, display selected settings in
        // ListBox1. These values can be used when printing the
        // document.
        if ( result == DialogResult.OK)
        {
            object[] results = new object[]{ 
                PageSetupDialog1.PageSettings.Margins, 
                PageSetupDialog1.PageSettings.PaperSize, 
                PageSetupDialog1.PageSettings.Landscape, 
                PageSetupDialog1.PrinterSettings.PrinterName, 
                PageSetupDialog1.PrinterSettings.PrintRange};
            ListBox1.Items.AddRange(results);
        }
    }

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

PageSetupDialog Class | PageSetupDialog Members | System.Windows.Forms Namespace | PageSettings