--- title: "How to: Determine Page Properties Using the PageSetupDialog Component" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "page properties" - "page setup" - "PageSetupDialog component" ms.assetid: 6dae05bc-c0fd-4357-bb93-841a1631d98f --- # How to: Determine Page Properties Using the PageSetupDialog Component The [PageSetupDialog](pagesetupdialog-component-windows-forms.md) component presents layout, paper size, and other page layout choices to the user for a document. You need to specify an instance of the class—this is the document to be printed. Additionally, users must have a printer installed on their computer, either locally or through a network, as this is partly how the component determines the page formatting choices presented to the user. An important aspect of working with the component is how it interacts with the class. The class is used to specify settings that modify the way a page will be printed, such as paper orientation, the size of the page, and the margins. Each of these settings is represented as a property of the class. The class modifies these property values for a given instance of the class that is associated with the document (and is represented as a property). ### To set page properties using the PageSetupDialog component 1. Use the method to display the dialog box, specifying the to use. In the example below, the control's event handler opens an instance of the component. An existing document is specified in the property, and its property is set to `false`. The example assumes your form has a control, a component named `myDocument`, and a component. ```vb Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click ' The print document 'myDocument' used below ' is merely for an example. 'You will have to specify your own print document. PageSetupDialog1.Document = myDocument ' Sets the print document's color setting to false, ' so that the page will not be printed in color. PageSetupDialog1.Document.DefaultPageSettings.Color = False PageSetupDialog1.ShowDialog() End Sub ``` ```csharp private void button1_Click(object sender, System.EventArgs e) { // The print document 'myDocument' used below // is merely for an example. // You will have to specify your own print document. pageSetupDialog1.Document = myDocument; // Sets the print document's color setting to false, // so that the page will not be printed in color. pageSetupDialog1.Document.DefaultPageSettings.Color = false; pageSetupDialog1.ShowDialog(); } ``` ```cpp private: System::Void button1_Click(System::Object ^ sender, System::EventArgs ^ e) { // The print document 'myDocument' used below // is merely for an example. // You will have to specify your own print document. pageSetupDialog1->Document = myDocument; // Sets the print document's color setting to false, // so that the page will not be printed in color. pageSetupDialog1->Document->DefaultPageSettings->Color = false; pageSetupDialog1->ShowDialog(); } ``` (Visual C# and Visual C++) Place the following code in the form's constructor to register the event handler. ```csharp this.button1.Click += new System.EventHandler(this.button1_Click); ``` ```cpp this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); ``` ## See also - - [How to: Create Standard Windows Forms Print Jobs](../advanced/how-to-create-standard-windows-forms-print-jobs.md) - [PageSetupDialog Component](pagesetupdialog-component-windows-forms.md)