PageSetupDialog Class

 

Enables users to change page-related print settings, including margins and paper orientation. This class cannot be inherited.

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

System::Object
  System::MarshalByRefObject
    System.ComponentModel::Component
      System.Windows.Forms::CommonDialog
        System.Windows.Forms::PageSetupDialog

public ref class PageSetupDialog sealed : CommonDialog

NameDescription
System_CAPS_pubmethodPageSetupDialog()

Initializes a new instance of the PageSetupDialog class.

NameDescription
System_CAPS_pubpropertyAllowMargins

Gets or sets a value indicating whether the margins section of the dialog box is enabled.

System_CAPS_pubpropertyAllowOrientation

Gets or sets a value indicating whether the orientation section of the dialog box (landscape versus portrait) is enabled.

System_CAPS_pubpropertyAllowPaper

Gets or sets a value indicating whether the paper section of the dialog box (paper size and paper source) is enabled.

System_CAPS_pubpropertyAllowPrinter

Gets or sets a value indicating whether the Printer button is enabled.

System_CAPS_pubpropertyContainer

Gets the IContainer that contains the Component.(Inherited from Component.)

System_CAPS_pubpropertyDocument

Gets or sets a value indicating the PrintDocument to get page settings from.

System_CAPS_pubpropertyEnableMetric

Gets or sets a value indicating whether the margin settings, when displayed in millimeters, should be automatically converted to and from hundredths of an inch.

System_CAPS_pubpropertyMinMargins

Gets or sets a value indicating the minimum margins, in hundredths of an inch, the user is allowed to select.

System_CAPS_pubpropertyPageSettings

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

System_CAPS_pubpropertyPrinterSettings

Gets or sets the printer settings that are modified when the user clicks the Printer button in the dialog.

System_CAPS_pubpropertyShowHelp

Gets or sets a value indicating whether the Help button is visible.

System_CAPS_pubpropertyShowNetwork

Gets or sets a value indicating whether the Network button is visible.

System_CAPS_pubpropertySite

Gets or sets the ISite of the Component.(Inherited from Component.)

System_CAPS_pubpropertyTag

Gets or sets an object that contains data about the control. (Inherited from CommonDialog.)

NameDescription
System_CAPS_pubmethodCreateObjRef(Type^)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the Component.(Inherited from Component.)

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodReset()

Resets all options to their default values.(Overrides CommonDialog::Reset().)

System_CAPS_pubmethodShowDialog()

Runs a common dialog box with a default owner.(Inherited from CommonDialog.)

System_CAPS_pubmethodShowDialog(IWin32Window^)

Runs a common dialog box with the specified owner.(Inherited from CommonDialog.)

System_CAPS_pubmethodToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.(Inherited from Component.)

NameDescription
System_CAPS_pubeventDisposed

Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)

System_CAPS_pubeventHelpRequest

Occurs when the user clicks the Help button on a common dialog box.(Inherited from CommonDialog.)

The PageSetupDialog dialog box modifies the PageSettings and PrinterSettings information for a given Document. The user can enable sections of the dialog box to manipulate printing and margins; paper orientation, size, and source; and to show Help and network buttons. The MinMargins property defines the minimum margins a user can select.

When you create an instance of the PageSetupDialog class, the read/write properties are set to initial values. For a list of these values, see the PageSetupDialog constructor.

Because a PageSetupDialog needs page settings to display, you need to set the Document, PrinterSettings, or PageSettings property before calling ShowDialog; otherwise, an exception will occur.

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.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{

   // Initialize the dialog's PrinterSettings property to hold user
   // defined printer settings.
   PageSetupDialog1->PageSettings = gcnew System::Drawing::Printing::PageSettings;

   // Initialize dialog's PrinterSettings property to hold user
   // set printer settings.
   PageSetupDialog1->PrinterSettings = gcnew System::Drawing::Printing::PrinterSettings;

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

   //Show the dialog storing the result.
   System::Windows::Forms::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 )
   {
      array<Object^>^results = {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

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: