PageSetupDialog.PageSettings Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public PageSettings PageSettings { get; set; }

Property Value

Type: System.Drawing.Printing.PageSettings

The PageSettings to modify. The default is null.

The following code example demonstrates the PageSetupDialog using the PageSettings, PrinterSettings, and ShowNetwork properties. To run this example, place it 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.


//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);
       }

   }

.NET Framework
Available since 1.1
Return to top
Show: