System.Windows.Forms
1.0.5000.0
2.0.0.0
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.ContainerControl
[System.ComponentModel.DefaultEvent("Load")]
[<System.ComponentModel.DefaultEvent("Load")>]
[System.ComponentModel.Designer("System.Windows.Forms.Design.FormDocumentDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.Design.IRootDesigner))]
[<System.ComponentModel.Designer("System.Windows.Forms.Design.FormDocumentDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.ComponentModel.Design.IRootDesigner))>]
[System.ComponentModel.DesignerCategory("Form")]
[<System.ComponentModel.DesignerCategory("Form")>]
[System.ComponentModel.DesignTimeVisible(false)]
[<System.ComponentModel.DesignTimeVisible(false)>]
[System.ComponentModel.InitializationEvent("Load")]
[<System.ComponentModel.InitializationEvent("Load")>]
[System.ComponentModel.ToolboxItem(false)]
[<System.ComponentModel.ToolboxItem(false)>]
[System.ComponentModel.ToolboxItemFilter("System.Windows.Forms.Control.TopLevel")]
[<System.ComponentModel.ToolboxItemFilter("System.Windows.Forms.Control.TopLevel")>]
[System.Runtime.CompilerServices.Nullable(0)]
[<System.Runtime.CompilerServices.Nullable(0)>]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[System.Runtime.InteropServices.ComVisible(true)]
[<System.Runtime.InteropServices.ComVisible(true)>]
Represents a window or dialog box that makes up an application's user interface.
is a representation of any window displayed in your application. The class can be used to create standard, tool, borderless, and floating windows. You can also use the class to create modal windows such as a dialog box. A special kind of form, the multiple-document interface (MDI) form, can contain other forms called MDI child forms. An MDI form is created by setting the property to `true`. MDI child forms are created by setting the property to the MDI parent form that will contain the child form.
Using the properties available in the class, you can determine the appearance, size, color, and window management features of the window or dialog box you are creating. The property allows you to specify the caption of the window in the title bar. The and properties allow you to define the size and position of the window when it is displayed. You can use the color property to change the default foreground color of all controls placed on the form. The , , and properties allow you to control whether the form can be minimized, maximized, or resized at run time.
In addition to properties, you can use the methods of the class to manipulate a form. For example, you can use the method to show a form as a modal dialog box. You can use the method to position the form on the desktop.
The events of the class allow you to respond to actions performed on the form. You can use the event to perform operations such as updating the data displayed in the controls of the form when the form is activated.
You can use a form as the starting class in your application by placing a method called `Main` in the class. In the `Main` method add code to create and show the form. You will also need to add the `STAThread` attribute to the `Main` method in order for the form to run. When the starting form is closed, the application is also closed.
If you set the property to `false` before the is visible (for example, setting to false in the Microsoft Visual Studio designer), the minimize, maximize, close, and system buttons remain enabled. If you set to `false` after the is visible (for example, when the Load event occurs), the buttons are disabled.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Multiple-Document Interface (MDI) Applications
Constructor
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
Initializes a new instance of the class.
and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also sets uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(null)]
[<System.ComponentModel.DefaultValue(null)>]
System.Windows.Forms.IButtonControl
Gets or sets the button on the form that is clicked when the user presses the ENTER key.
An that represents the button to use as the accept button for the form.
that is on the current form or located within a container on the current form.
You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ENTER key when they are finished instead of manually clicking the accept button with their mouse.
The accept button might not be activated if the currently selected control on the form intercepts the ENTER key and processes it. For example, a multiline text box control allows the ENTER key to be pressed when it is selected to insert a new line character in the control.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
Activates the form and gives it focus.
property or the property if your forms are in a Multiple-document interface (MDI) application.
## Examples
The following example demonstrates how to use the , and members. To run the example, paste the following code in a form called `Form1` containing a button called `Button1` and two `Label` controls called `Label1` and `Label2`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FormsActivate/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Activate/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Activate/form1.vb" id="Snippet1":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when the form is activated in code or by the user.
[!NOTE]
> When the application is active and has multiple forms, the active form is the form with the input focus. A form that is not visible cannot be the active form. The simplest way to activate a visible form is to click it or use an appropriate keyboard combination.
To activate a form at run time using code, call the method. You can use this event for tasks such as updating the contents of the form based on changes made to the form's data when the form was not activated.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates how to use the , , , , and members. To run the example, paste the following code in a form called Form1 containing a called `Button1` and two controls called `Label1` and `Label2`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FormsActivate/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Activate/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Activate/form1.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
The child form to activate.
Activates the MDI child of a form.
method simply returns. If `form` is not `null`, then it is set to be the active MDI child form.
Whether the `form` parameter is `null` or not, raises the event.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.Form
Gets the currently active form for this application.
A that represents the currently active form, or if there is no active form.
property to obtain the currently active MDI child form.
## Examples
The following example gets the active form and disables all the controls on the form. The example uses the collection of the form to iterate through each control on the form and disable the controls.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.ActiveForm Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ActiveForm/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ActiveForm/source.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Windows.Forms.Form
Gets the currently active multiple-document interface (MDI) child window.
Returns a that represents the currently active MDI child window, or if there are currently no child windows present.
property to obtain a reference to it.
## Examples
The following example obtains a reference to the active MDI child form and loops through all controls on the form, resetting their properties. This example requires that an MDI parent form has been created and that this method call is being made from the MDI parent form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.ActiveMdiChild Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ActiveMdiChild/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ActiveMdiChild/source.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
The that this form will own.
Adds an owned form to this form.
method is called. You can also make a form owned by another by setting the property with a reference to its owner form.
When a form is owned by another form, it is closed or hidden with the owner form. For example, consider a form named `Form2` that is owned by a form named `Form1`. If `Form1` is closed or minimized, `Form2` is also closed or hidden. Owned forms are also never displayed behind their owner form. You can use owned forms for windows such as find and replace windows, which should not be displayed behind the owner form when the owner form is selected.
> [!NOTE]
> If the form is a multiple-document interface (MDI) parent form, this property returns all forms that are displayed with the exception of any MDI child forms that are currently open. To obtain the MDI child forms opened in an MDI parent form, use the property.
## Examples
The following example demonstrates how to use the method to display a form as an owned form of another form. Once the owned form is shown, you can minimize its owner form and the owned form will minimize with it. The example requires that the code in the example is called from another event or method of a form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.AddOwnedForm/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/AddOwnedForm/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/AddOwnedForm/form1.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
to show the scroll bars; otherwise, .
Adjusts the scroll bars on the container based on the current control positions and the control currently selected.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Boolean
Gets or sets a value indicating whether the opacity of the form can be adjusted.
if the opacity of the form can be changed; otherwise, .
property to `false` the form will not be in layered mode which will improve the display performance of the form.
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("This method has been deprecated. Use the ApplyAutoScaling method instead. https://go.microsoft.com/fwlink/?linkid=14202")]
[<System.Obsolete("This method has been deprecated. Use the ApplyAutoScaling method instead. https://go.microsoft.com/fwlink/?linkid=14202")>]
[System.Obsolete("This method has been deprecated. Use the ApplyAutoScaling method instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[<System.Obsolete("This method has been deprecated. Use the ApplyAutoScaling method instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
System.Void
Resizes the form according to the current value of the property and the size of the current font.
property and the value returned by the method.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("This property has been deprecated. Use the AutoScaleMode property instead. https://go.microsoft.com/fwlink/?linkid=14202")]
[<System.Obsolete("This property has been deprecated. Use the AutoScaleMode property instead. https://go.microsoft.com/fwlink/?linkid=14202")>]
[System.Obsolete("This property has been deprecated. Use the AutoScaleMode property instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[<System.Obsolete("This property has been deprecated. Use the AutoScaleMode property instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
System.Boolean
Gets or sets a value indicating whether the form adjusts its size to fit the height of the font used on the form and scales its controls.
if the form will automatically scale itself and its controls based on the current font assigned to the form; otherwise, . The default is .
[!IMPORTANT]
> The is obsolete and has been retained for backward compatibility. The non-obsolete alternative is . For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms).
You can use this property to allow your form and its controls to automatically adjust based on changes in the font. This can be useful in applications where the font might increase or decrease based on the language specified for use by Windows.
To obtain the size the form will auto scale to, use the property. If you want to determine the size the form will auto scale to based on a specific font, use the method.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Drawing.Size
Gets or sets the base size used for autoscaling of the form.
A that represents the base size that this form uses for autoscaling.
[!IMPORTANT]
> This member has been retained for backward compatibility. For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms).
The value of the property is used at form-display time to compute the scaling factor for the form. The autoscaling base size is used by the form as a baseline for comparison to the system's font size to determine how much to scale the form when autoscaling is used. If you want to determine the size a form will auto scale to based on a specific font, use the method.
> [!NOTE]
> The value of this property is used when the form is initially created. Once the property is set, it cannot be changed.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Boolean
Gets or sets a value indicating whether the form enables autoscrolling.
to enable autoscrolling on the form; otherwise, . The default is .
property to enable the display of controls that are outsize the client area of a form. The example creates a new form and adds a control to the form. The control is positioned outsize the client area of the new form. The property is set to true to display scroll bars on the form to enable the user to scroll to the control. This example requires that the method defined in this example is called from another form in an event handler or other method.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.AutoScroll/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/AutoScroll/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/AutoScroll/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.Boolean
Resize the form according to the setting of .
if the form will automatically resize; if it must be manually resized.
to force a form to resize to fit its contents.
A form does not automatically resize in the Visual Studio forms designer, regardless of the values of the and properties. The form correctly resizes itself at run time according to the values of these two properties. By contrast, a custom automatically resizes itself both at design time and at run time.
When using , the and properties are respected, but the current value of the property is ignored. Using and also renders the property superfluous, as there is no way to shrink the form to hide its contained controls from view.
See the enumeration for information on how a form behaves when is `true`.
## Examples
The following example shows a form created using code that automatically resizes to fit its contents. When run, the form displays a , a for entering a URL, and a for displaying that URL inside of the user's default Web browser. The example uses a to lay out the contained controls one after the other. It also sets the and to grow and shrink to fit the contents of its form.
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/AutoSizeMode/Overview/Form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/AutoSizeMode/Overview/Form1.vb" id="Snippet1":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.EventHandler
Occurs when the property changes.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.DefaultValue(System.Windows.Forms.AutoSizeMode.GrowOnly)]
[<System.ComponentModel.DefaultValue(System.Windows.Forms.AutoSizeMode.GrowOnly)>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Windows.Forms.AutoSizeMode
Gets or sets the mode by which the form automatically resizes itself.
An enumerated value. The default is .
property to a new value causes the form to be laid out again.
A form does not automatically resize in the Visual Studio forms designer, regardless of the values of the and properties. The form correctly resizes itself at run time according to the values of these two properties. By contrast, a custom automatically resizes itself both at design time and at run time.
## Examples
The following example shows a form created using code that automatically resizes to fit its contents. When run, the form displays a , a for entering a URL, and a for displaying that URL inside of the user's default Web browser. The example uses a to lay out the contained controls one after the other. It also sets the and to grow and shrink to fit the contents of its form.
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/AutoSizeMode/Overview/Form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/AutoSizeMode/Overview/Form1.vb" id="Snippet1":::
]]>
The value is not a valid value.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.Windows.Forms.AutoValidate
Gets or sets a value that indicates whether controls in this container will be automatically validated when the focus changes.
An enumerated value that indicates whether contained controls are implicitly validated on focus change. The default is Inherit.
To be added.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.EventHandler
Occurs when the property changes.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Drawing.Color
Gets or sets the background color for the control.
A that represents the background color of the control. The default is the value of the property.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(null)]
[<System.ComponentModel.DefaultValue(null)>]
System.Windows.Forms.IButtonControl
Gets or sets the button control that is clicked when the user presses the ESC key.
An that represents the cancel button for the form.
that is on the current form or located within a container on the current form.
This property allows you to designate a default action to occur when the user presses the ESC key in your application. You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ESC key to close a window without committing changes instead of manually clicking the cancel button with their mouse.
may not work if another control on the form intercepts the ESC key. For example, if you have a open on your form, ESC will close the instead of closing the Form.
The object assigned to must be visible on the form, or else pressing the ESC key will have no effect.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
Centers the position of the form within the bounds of the parent form.
method directly from your code. Instead, set the property to .
If the form or dialog is top-level, then centers the form with respect to the screen or desktop.
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
Centers the form on the current screen.
property to .
The method uses the following priority list to determine the screen used to center the form:
1. The property of the form.
2. The HWND owner of the form.
3. The screen that currently has the mouse cursor.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Drawing.Size
Gets or sets the size of the client area of the form.
A that represents the size of the form's client area.
property or use the individual properties and .
> [!NOTE]
> You cannot currently bind to this property using application settings. For more information on application settings, see [Application Settings Overview](/dotnet/desktop/winforms/advanced/application-settings-overview).
## Examples
The following example creates an event handler for the event of a form. The event handler uses the property of the form to make a control named `button1` fill the entire client area of the form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.ClientSize Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ClientSize/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ClientSize/source.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
Closes the form.
event and setting the property of the passed as a parameter to your event handler. If the form you are closing is the startup form of your application, your application ends.
The two conditions when a form is not disposed on `Close` is when (1) it is part of a multiple-document interface (MDI) application, and the form is not visible; and (2) you have displayed the form using . In these cases, you will need to call manually to mark all of the form's controls for garbage collection.
> [!NOTE]
> When the method is called on a displayed as a modeless window, you cannot call the method to make the form visible, because the form's resources have already been released. To hide a form and then make it visible, use the method.
]]>
The form was closed while a handle was being created.
You cannot call this method from the event when is set to .
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.EventHandler
Occurs when the form is closed.
[!CAUTION]
> The event is obsolete in .NET Framework version 2.0; use the event instead.
This event occurs after the form has been closed by the user or by the method of the form. To prevent a form from closing, handle the event and set the property of the passed to your event handler to `true`.
You can use this event to perform tasks such as freeing resources used by the form and to save information entered in the form or to update its parent form.
> [!CAUTION]
> The and events are not raised when the method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the method for each open form individually before calling the method.
If the form is an MDI parent form, the events of all MDI child forms are raised before the MDI parent form's event is raised. In addition, the events of all MDI child forms are raised before the event of the MDI parent form is raised.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.ComponentModel.CancelEventHandler
Occurs when the form is closing.
[!CAUTION]
> The event is obsolete; use the event instead.
The event occurs as the form is being closed. When a form is closed, all resources created within the object are released and the form is disposed. If you cancel this event, the form remains opened. To cancel the closure of a form, set the property of the passed to your event handler to `true`.
When a form is displayed as a modal dialog box, clicking the **Close** button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the property to be set to `DialogResult.Cancel`. You can override the value assigned to the property when the user clicks the **Close** button by setting the property in an event handler for the event of the form.
> [!NOTE]
> When the method is called on a displayed as a modeless window, you cannot call the method to make the form visible, because the form's resources have already been released. To hide a form and then make it visible, use the method.
> [!CAUTION]
> The and events are not raised when the method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the method for each open form individually before calling the method.
If the form is an MDI parent form, the events of all MDI child forms are raised before the MDI parent form's event is raised. In addition, the events of all MDI child forms are raised before the event of the MDI parent form is raised. Canceling the event of an MDI child form does not prevent the event of the MDI parent form from being raised. However, canceling the event will set to `true` the property of the that is passed as a parameter to the parent form. To force all MDI parent and child forms to close, set the property to `false` in the MDI parent form.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
System.Boolean
Gets or sets a value indicating whether a control box is displayed in the caption bar of the form.
if the form displays a control box in the upper-right corner of the form; otherwise, . The default is .
property is set to `true`, the control box is displayed in the upper-right corner of the caption bar. The control box can include minimize, maximize, and help buttons in addition to a close button. For the `ControlBox` property to have any effect, you must also set the form's property to , , , or .
If you set to `false` and also set the property, the property of the form is not updated to reflect that the non-client area of the form has been hidden. To fix this problem, put the code that alters the property in the event handler.
> [!NOTE]
> When set to `false`, the property has no effect on a Multiple-document interface (MDI) child form that is displayed maximized at time of creation.
## Examples
The following example uses the , , , , and properties to create a form that does not have any border or caption box. The form created in this example could be used to create a splash screen for an application. The example requires that the example's method is defined in a form class and called when the form is being initialized.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.ControlBox Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ControlBox/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ControlBox/source.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.AccessibleObject
Creates a new accessibility object for the control.
A new accessible object for the control.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Windows.Forms.Control+ControlCollection
Creates a new instance of the control collection for the control.
A new instance of assigned to the control.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
Creates the handle for the form. If a derived class overrides this function, it must call the base implementation.
To be added.
A handle for this has already been created.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.Runtime.CompilerServices.Nullable(1)]
[<System.Runtime.CompilerServices.Nullable(1)>]
System.Windows.Forms.CreateParams
Gets the required creation parameters when the control handle is created.
A that contains the required creation parameters when the handle to the control is created.
To be added.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when the form loses focus and is no longer the active form.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet393":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet393":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.ImeMode
Gets the default Input Method Editor (IME) mode supported by the control.
One of the values.
class, this property always returns the value. The value of this property is assigned to the property.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Drawing.Size
Gets the default size of the control.
The default of the control.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The Windows to process.
Sends the specified message to the default window procedure.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Drawing.Rectangle
Gets or sets the size and location of the form on the Windows desktop.
A that represents the bounds of the form on the Windows desktop using desktop coordinates.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Drawing.Point
Gets or sets the location of the form on the Windows desktop.
A that represents the location of the form on the desktop.
method before calling the method, your form will be positioned at its default location, which is determined by the operating system. For more information about window positioning, see the [Window Size and Position](/windows/win32/winmsg/window-features#window-size-and-position) section of the "Window Features" article.
If you call after calling , your form will be positioned at the location you specified.
## Examples
The following example sets the position of a form so that the form is positioned 100 pixels from the left border of the desktop and 100 pixels from the top of the desktop. This example requires that method has been defined within a form class.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.DesktopLocation Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/DesktopLocation/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/DesktopLocation/source.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Windows.Forms.DialogResult
Gets or sets the dialog result for the form.
A that represents the result of the form when used as a dialog box.
enumeration sets the value of the dialog box result for the form, hides the modal dialog box, and returns control to the calling form. This property is typically set by the property of a control on the form. When the user clicks the control, the value assigned to the property of the is assigned to the property of the form.
When a form is displayed as a modal dialog box, clicking the **Close** button (the button with an X in the top-right corner of the form) causes the form to be hidden and the property to be set to `DialogResult.Cancel`. The method is not automatically called when the user clicks the **Close** button of a dialog box or sets the value of the property. Instead, the form is hidden and can be shown again without creating a new instance of the dialog box. Because of this behavior, you must call the method of the form when the form is no longer needed by your application.
You can use this property to determine how a dialog box is closed in order to properly process the actions performed in the dialog box.
> [!NOTE]
> You can override the value assigned to the property when the user clicks the **Close** button by setting the property in an event handler for the event of the form.
> [!NOTE]
> If a is displayed as a modeless window, the value returned by the property might not return a value assigned to the form because the form's resources are automatically released when the form is closed.
## Examples
The following example displays a form as a dialog box and displays a message box indicating whether the OK or Cancel button of the form was clicked by referencing the property of the form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.DialogResult Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/DialogResult/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/DialogResult/source.vb" id="Snippet1":::
]]>
The value specified is outside the range of valid values.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
to release both managed and unmanaged resources; to release only unmanaged resources.
Disposes of the resources (other than memory) used by the .
method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`.
When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose` method of each referenced object.
will be called automatically if the form is shown using the method. If another method such as is used, or the form is never shown at all, you must call yourself within your application.
]]>
can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed of in an earlier call to . For more information about how to implement , see Implementing a Dispose Method.
For more information about and , see Cleaning Up Unmanaged Resources.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.DpiChangedEventHandler
Occurs when the DPI setting changes on the display device where the form is currently displayed.
To be added.
Property
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Drawing.Color
Sets or gets the Form's border color.
The which has be previously set using this property or .
Note that the underlying Win32 API does not provide a reliable mechanism to retrieve the current border color.
Note: Reading this property is only for tracking purposes. If the Form's border color is changed through other external means (Win32 calls),
reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color.
The property only reflects the value that was previously set using this property. The
event is raised accordingly when the value is changed, which allows the property to be participating in binding scenarios.
Event
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.EventHandler
Occurs when the property has changed.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(System.Windows.Forms.FormBorderStyle.Sizable)]
[<System.ComponentModel.DefaultValue(System.Windows.Forms.FormBorderStyle.Sizable)>]
[System.Runtime.InteropServices.DispId(-504)]
[<System.Runtime.InteropServices.DispId(-504)>]
System.Windows.Forms.FormBorderStyle
Gets or sets the border style of the form.
A that represents the style of border to display for the form. The default is .
[!NOTE]
> With the style, it is impossible to resize the window below a certain minimum value, even if you have set to `false` and assigned a zero-length string to . Consider working around this by using the style instead.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
The value specified is outside the range of valid values.
Property
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Drawing.Color
Sets or gets the Form's title bar back color (caption back color).
The , which has be previously set using this property or .
Note that the underlying Win32 API does not provide a reliable mechanism to retrieve the current title bar color.
Reading this property is only for tracking purposes. If the window's title bar color is changed through other external means (Win32 calls),
reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color.
The property only reflects the value that was previously set using this property. The
event is raised accordingly when the value is changed, which allows the property to be participating in binding scenarios.
Event
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.EventHandler
Occurs when the property has changed.
To be added.
Property
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Drawing.Color
Sets or gets the Form's title bar text color (windows caption text color).
The , which has be previously set using this property or .
Note that the underlying Win32 API does not provide a reliable mechanism to retrieve the current title bar text color.
Reading this property is only for tracking purposes. If the Form's title bar's text color (window caption text) is changed through other external means (Win32 calls),
reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color.
The property only reflects the value that was previously set using this property. The
event is raised accordingly when the value is changed, which allows the property to be participating in binding scenarios.
Event
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.EventHandler
Occurs when the property has changed.
To be added.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.FormClosedEventHandler
Occurs after the form is closed.
event occurs after the form has been closed by the user or by the method or the method of the class. To prevent a form from closing, handle the event and set the property of the passed to your event handler to `true`.
You can use this event to perform tasks such as freeing resources used by the form and to save information entered in the form or to update its parent form.
If the form is a multiple-document interface (MDI) parent form, the events of all MDI child forms are raised before the MDI parent form's event is raised. Likewise, the events of all MDI child forms are raised before the event of the MDI parent form is raised.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet395":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet395":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.FormClosingEventHandler
Occurs before the form is closed.
event occurs as the form is being closed. When a form is closed, it is disposed, releasing all resources associated with the form. If you cancel this event, the form remains opened. To cancel the closure of a form, set the property of the passed to your event handler to `true`.
When a form is displayed as a modal dialog box, clicking the **Close** button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the property to be set to `DialogResult.Cancel`. You can override the value assigned to the property when the user clicks the **Close** button by setting the property in an event handler for the event of the form.
> [!NOTE]
> When the method is called on a displayed as a modeless window, you cannot call the method to make the form visible, because the form's resources have already been released. To hide a form and then make it visible, use the method.
If the form is a multiple-document interface (MDI) parent form, the events of all MDI child forms are raised before the MDI parent form's event is raised. Likewise, the events of all MDI child forms are raised before the event of the MDI parent form is raised. Canceling the event of an MDI child form does not prevent the event of the MDI parent form from being raised. However, canceling the event will set to `true` the property of the class that is passed as a parameter to the parent form. To force all MDI parent and child forms to close, set the property to `false` in the MDI parent form.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet394":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet394":::
]]>
Property
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DefaultValue(System.Windows.Forms.FormCornerPreference.Default)]
[<System.ComponentModel.DefaultValue(System.Windows.Forms.FormCornerPreference.Default)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Windows.Forms.FormCornerPreference
Sets or gets the rounding style of the Form's corners using the enum.
To be added.
Reading this property is only for tracking purposes. If the Form's corner preference is changed through other external means (Win32 calls),
reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color.
The property only reflects the value that was previously set using this property. The
event is raised accordingly when the value is changed, which allows the property to be participating in binding scenarios.
Event
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.EventHandler
Occurs when the property has changed.
To be added.
Property
System.Windows.Forms
10.0.0.0
11.0.0.0
System.Windows.Forms.ScreenCaptureMode
To be added.
To be added.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("This method has been deprecated. Use the AutoScaleDimensions property instead. https://go.microsoft.com/fwlink/?linkid=14202")]
[<System.Obsolete("This method has been deprecated. Use the AutoScaleDimensions property instead. https://go.microsoft.com/fwlink/?linkid=14202")>]
[System.Obsolete("This method has been deprecated. Use the AutoScaleDimensions property instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[<System.Obsolete("This method has been deprecated. Use the AutoScaleDimensions property instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
System.Drawing.SizeF
A representing the font to determine the autoscaled base size of the form.
Gets the size when autoscaling the form based on a specified font.
A representing the autoscaled size of the form.
[!IMPORTANT]
> The method is obsolete. This member has been retained for backward compatibility. For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms).
You can use this method to determine the size a form would autoscale to for a specific font before applying the font to the form. If you want to determine the size a form is autoscaled to based on the font currently assigned to the form, use the property.
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Drawing.Rectangle
A that specifies the area for which to retrieve the display bounds.
The height and width of the control's bounds.
One of the values of that specifies the bounds of the control to use when defining its size and position.
Retrieves the bounds within which the control is scaled.
A representing the bounds within which the control is scaled.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(false)]
[<System.ComponentModel.DefaultValue(false)>]
System.Boolean
Gets or sets a value indicating whether a Help button should be displayed in the caption box of the form.
to display a Help button in the form's caption bar; otherwise, . The default is .
event to display Help information to the user when the Help button of the form is clicked.
To display a Help button, the value of the form's property must be `true`, its default value. The property determines whether the upper-right corner of the caption bar contains controls such as a maximize button, a minimize button, a help button, and a close button. In addition, you must also set the form's property to , , , or .
> [!IMPORTANT]
> The value of the property is ignored if the **Maximize** or **Minimize** buttons are shown.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a Help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.ComponentModel.CancelEventHandler
Occurs when the **Help** button is clicked.
event occurs when the **Help** button in the form's caption bar is clicked. The **Help** button is displayed when the property is set to `true`. can be canceled.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet388":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet388":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.AmbientValue(null)]
[<System.ComponentModel.AmbientValue(null)>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Drawing.Icon
Gets or sets the icon for the form.
An that represents the icon for the form.
is set to . In that case, the form will not display an icon.
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.InputLanguageChangedEventHandler
Occurs after the input language of the form has changed.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet400":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet400":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.InputLanguageChangingEventHandler
Occurs when the user attempts to change the input language for the form.
property of the passed to your event handler to `false`. If the event is canceled, the input language is not changed. You can use this event to determine whether the requested input language change is appropriate for your application.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet401":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet401":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiParentInternal")]
[<System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiParentInternal")>]
[get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiParentInternal")]
[<get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiParentInternal")>]
System.Boolean
Gets a value indicating whether the form is a multiple-document interface (MDI) child form.
if the form is an MDI child form; otherwise, .
that will be the MDI parent form to the property of the child form. You can use the property to determine whether a form is an MDI parent form.
You can use the property to determine whether a form returned by a method or property is an MDI child form or a standard form in your application such as a dialog box.
> [!NOTE]
> All MDI child forms have sizable borders, a control-menu box, and Minimize and **Maximize** buttons, regardless of the settings of the , , , and properties.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(false)]
[<System.ComponentModel.DefaultValue(false)>]
[System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiClient")]
[<System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiClient")>]
[get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiClient")]
[<get: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiClient")>]
[set: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiClient")]
[<set: System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, "MdiClient")>]
System.Boolean
Gets or sets a value indicating whether the form is a container for multiple-document interface (MDI) child forms.
if the form is a container for MDI child forms; otherwise, . The default is .
events of all MDI child forms are raised before the MDI parent form's event is raised. In addition, the events of all MDI child forms are raised before the event of the MDI parent form is raised.
> [!NOTE]
> If there are two controls on an MDI child form, setting to `true` for the parent form merges the contents of only one of the controls. Use to merge the contents of additional child controls on the MDI parent form.
## Examples
The following example demonstrates using the property as well as changing the `BackColor` property of an MDI Form. To run this example, paste the following code in a new form.
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/IsMdiContainer/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/IsMdiContainer/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Boolean
Gets a value indicating whether the form can use all windows and user input events without restriction.
if the form has restrictions; otherwise, . The default is .
property determines whether the permission is granted. This property is set at run time in the form's constructor, and is cached for the lifetime of the form. Windows Forms applications running in partial trust cannot circumvent this check, as the common language runtime ensures that the parent constructor is always called in partial trust.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(false)]
[<System.ComponentModel.DefaultValue(false)>]
System.Boolean
Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.
if the form will receive all key events; if the currently selected control on the form receives key events. The default is .
, , and events. After the form's event handlers have completed processing the keystroke, the keystroke is then assigned to the control with focus. For example, if the property is set to `true` and the currently selected control is a , after the keystroke is handled by the event handlers of the form the control will receive the key that was pressed. To handle keyboard events only at the form level and not allow controls to receive keyboard events, set the property in your form's event handler to `true`.
You can use this property to process most keystrokes in your application and either handle the keystroke or call the appropriate control to handle the keystroke. For example, when an application uses function keys, you might want to process the keystrokes at the form level rather than writing code for each control that might receive keystroke events.
> [!NOTE]
> If a form has no visible or enabled controls, it automatically receives all keyboard events.
> [!NOTE]
> A control on a form may be programmed to cancel any keystrokes it receives. Since the control never sends these keystrokes to the form, the form will never see them regardless of the setting of .
## Examples
The following example demonstrates setting a form's property to true and handling the key events at the form level. To run the example, paste the following code in a blank form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProcessMnemonic/CPP/form1.cpp" id="Snippet2":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/ProcessMnemonic/form1.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/CheckBox/ProcessMnemonic/form1.vb" id="Snippet2":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
One of the values that defines the layout of MDI child forms.
Arranges the multiple-document interface (MDI) child forms within the MDI parent form.
method to arrange any child forms that are currently open in the application.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.LayoutMdi Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/LayoutMdi/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/LayoutMdi/source.vb" id="Snippet1":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs before a form is displayed for the first time.
, , , and members. To run the example, paste the following code in a form called `Form1` containing a called `Button1` and two controls called `Label1` and `Label2`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FormsActivate/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Activate/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Activate/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.SettingsBindable(true)]
[<System.ComponentModel.SettingsBindable(true)>]
System.Drawing.Point
Gets or sets the that represents the upper-left corner of the in screen coordinates.
The that represents the upper-left corner of the in screen coordinates.
is a structure, which means that it is a value type. If you access a property in , a copy of the property is returned. Therefore, changing the or properties of the returned from the property will not affect the , , , or property values of the . To adjust these properties, set each property value individually, or set the property with a new .
The property gets or sets the property of the base class, and sets the property to `true`.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(null)]
[<System.ComponentModel.DefaultValue(null)>]
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))]
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))>]
System.Windows.Forms.MenuStrip
Gets or sets the primary menu container for the form.
A that represents the container for the menu structure of the form. The default is .
property, you must the control to the collection of the form.
The class supersedes the class in previous versions of the .NET Framework.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
System.Windows.Forms.Padding
Gets or sets the space between controls.
A value that represents the space between controls.
To be added.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
System.EventHandler
Occurs when the property changes.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
System.Boolean
Gets or sets a value indicating whether the **Maximize** button is displayed in the caption bar of the form.
to display a **Maximize** button for the form; otherwise, . The default is .
property must be `true`, its default value. The property determines whether the upper-right corner of the caption bar contains controls such as a maximize button, a minimize button, a help button, and a close button. In addition, you must also set the form's property to , , , or .
A **Maximize** button automatically becomes a restore button when a window is maximized. Minimizing or restoring a window automatically changes the restore button back to a **Maximize** button.
> [!NOTE]
> Maximizing a form at run time generates a event. The property reflects the current state of the window. If you set the property to `FormWindowState.Maximized`, the form is maximized independently of whatever settings are in effect for the and properties.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Drawing.Rectangle
Gets or sets the size of the form when it is maximized.
A that represents the bounds of the form when it is maximized.
To be added.
The value of the property is greater than the height of the form.
-or-
The value of the property is greater than the width of the form.
Classes that inherit from can override this method to provide new bounds for the form when it is maximized. The class sets this property internally when the form's **Maximize** button is clicked.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when the value of the property has changed.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet389":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet389":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(typeof(System.Drawing.Size), "0, 0")]
[<System.ComponentModel.DefaultValue(typeof(System.Drawing.Size), "0, 0")>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
[<System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)>]
System.Drawing.Size
Gets the maximum size the form can be resized to.
A that represents the maximum size for the form.
object that is 0 in height and 0 in width, the form will have no maximum size beyond the limits set by Windows.
## Examples
The following example demonstrates setting the property.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FormExample/CPP/form1.cpp" id="Snippet3":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/MaximumSize/form1.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/MaximumSize/form1.vb" id="Snippet3":::
]]>
The values of the height or width within the object are less than zero.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when the value of the property has changed.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet390":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet390":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when a multiple-document interface (MDI) child form is activated or closed within an MDI application.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet397":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet397":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Runtime.CompilerServices.Nullable(1)]
[<System.Runtime.CompilerServices.Nullable(1)>]
System.Windows.Forms.Form[]
Gets an array of forms that represent the multiple-document interface (MDI) child forms that are parented to this form.
An array of objects, each of which identifies one of this form's MDI child forms.
that will be the MDI parent form to the property of the child form.
You can use this property to loop through all the MDI child forms to perform operations such as saving data to a database when the MDI parent form closes or to update fields on the child forms based on actions performed in your application.
## Examples
The following example demonstrates how to use the property to iterate through the list of MDI child forms and add a control to each.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.MDIChildren/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/MdiChildren/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/MdiChildren/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
System.Boolean
Gets or sets the anchoring for minimized MDI children.
to anchor minimized MDI children to the bottom left of the parent form; to anchor to the top left of the parent form.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Windows.Forms.Form
Gets or sets the current multiple-document interface (MDI) parent form of this form.
A that represents the MDI parent form.
that will be the MDI parent form to the property of the child form. You can use this property from an MDI child form to obtain global information that all child forms need or to invoke methods that perform actions to all child forms.
> [!NOTE]
> If there are two controls on an MDI child form, setting to `true` for the parent form merges the contents of only one of the controls. Use to merge the contents of additional child controls on the MDI parent form.
## Examples
The following example demonstrates how to create child forms in an MDI application. The example code creates a form with unique text to identify the child form. The example uses the property to specify that a form is a child form. This example requires that the code in the example is called from a form that has its property set to `true` and that the form has a private class level integer variable named `childCount`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.MDIParent/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/MdiParent/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/MdiParent/form1.vb" id="Snippet1":::
]]>
The assigned to this property is not marked as an MDI container.
-or-
The assigned to this property is both a child and an MDI container form.
-or-
The assigned to this property is located on a different thread.
Property
System.Windows.Forms
4.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("`MainMenu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `MenuStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Obsolete("`MainMenu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `MenuStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
[System.Runtime.CompilerServices.Nullable(0)]
[<System.Runtime.CompilerServices.Nullable(0)>]
[System.ComponentModel.DefaultValue(null)]
[<System.ComponentModel.DefaultValue(null)>]
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))]
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ReferenceConverter))>]
System.Windows.Forms.MainMenu
Gets or sets the that is displayed in the form.
A that represents the menu to display in the form.
to be displayed when your multiple-document interface (MDI) form has no active MDI child forms and another to display when a child window is displayed. You can also use a different when specific conditions exist in your application that require displaying a different menu set.
## Examples
The following example creates a , assigns two objects to the and binds it to a form. This example requires that you have a created that is named `Form1`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Menu/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Menu/source.vb" id="Snippet1":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
System.EventHandler
Occurs when the menu of a form loses focus.
control or enabling and disabling buttons on a .
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet398":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet398":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
System.EventHandler
Occurs when the menu of a form receives focus.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet399":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet399":::
]]>
Property
System.Windows.Forms
4.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("`MainMenu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `MenuStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Obsolete("`MainMenu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `MenuStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
[System.Runtime.CompilerServices.Nullable(0)]
[<System.Runtime.CompilerServices.Nullable(0)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Windows.Forms.MainMenu
Gets the merged menu for the form.
A that represents the merged menu of the form.
assigned to a form, use the property.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
System.Boolean
Gets or sets a value indicating whether the **Minimize** button is displayed in the caption bar of the form.
to display a **Minimize** button for the form; otherwise, . The default is .
property must be `true`, its default value. The property determines whether the upper-right corner of the caption bar contains controls such as a maximize button, a minimize button, a help button, and a close button. In addition, you must also set the form's property to , , , or .
> [!NOTE]
> Minimizing a form at run time generates a event. The property reflects the current state of the window. If you set the property to `FormWindowState.Minimized`, the form is minimized independently of whatever settings are in effect for the and properties.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.AcceptButton Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Overview/source.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
[<System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)>]
System.Drawing.Size
Gets or sets the minimum size the form can be resized to.
A that represents the minimum size for the form.
object that is 0 in height and 0 in width, the form will have no minimum size beyond the limits set by Windows.
]]>
The values of the height or width within the object are less than zero.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when the value of the property has changed.
event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet391":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet391":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Boolean
Gets a value indicating whether this form is displayed modally.
if the form is displayed modally; otherwise, .
method.
## Examples
The following example uses the property to determine if a form is displayed as a modal form. If it is not the and properties are changed to make the form a non-top-level form with a tool window border.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.Modal/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Modal/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Modal/form1.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. Overriding this method is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
An that contains the data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
An that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
[!CAUTION]
> The method is obsolete; use the method instead.
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. Overriding this method is the preferred technique for handling the event in a derived class.
> [!CAUTION]
> The and methods are not called when the method is called to exit your application. If you have validation code in either of these methods that must be executed, you should call the method for each open form individually before calling the method.
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
[!CAUTION]
> The method is obsolete; use the method instead.
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. Overriding this method is the preferred technique for handling the event in a derived class.
> [!CAUTION]
> The and methods are not called when the method is called to exit your application. If you have validation code in either of these methods that must be executed, you should call the method for each open form individually before calling the method.
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
Raises the event.
When overriding in a derived class, be sure to call the base class's method.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Void
An that contains the event data, in this case empty.
Raises the event when the property changes.
To be added.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Void
An that contains the event data, in this case empty.
Raises the event when the property changes.
To be added.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Void
An that contains the event data, in this case empty.
Raises the event when the property changes.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
method removes the current form from the collection of the associated .
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. Overriding this method is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Void
An that contains the event data, in this case empty.
Raises the event when the property changes.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Boolean
The DPI value for the display device where the form was previously displayed.
The DPI value for the display device where the form will be displayed.
A representing the new size of the form based on the new DPI value.
Raises the GetDpiScaledSize event.
if successful; otherwise .
To be added.
Method
System.Windows.Forms
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
To be added.
To be added.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
The event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
event will only be raised if the form's property is set to `true`.
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
event will only be raised if the form's property is set to `true`.
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
method will return without performing any action. If the property of the form has a value of , then the handles of the form and its child controls will be recreated through calls to the method.
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
A that contains the event data.
Raises the event.
event occurs whenever the form is first shown.
Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/).
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
An that contains the event data.
Raises the event.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The that contains the event data.
Raises the event.
method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
]]>
When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(1)]
[<System.ComponentModel.DefaultValue(1)>]
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.OpacityConverter))]
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.OpacityConverter))>]
System.Double
Gets or sets the opacity level of the form.
The level of opacity for the form. The default is 1.00.
property enables you to specify a level of transparency for the form and its controls. When this property is set to a value less than 100 percent (1.00), the entire form, including borders, is made more transparent. Setting this property to a value of 0 percent (0.00) makes the form completely invisible. You can use this property to provide different levels of transparency or to provide effects such as phasing a form in or out of view. For example, you can phase a form into view by setting the property to a value of 0 percent (0.00) and gradually increasing the value until it reaches 100 percent (1.00).
differs from the transparency provided by , which only makes a form and its controls completely transparent if they are the same color as the value specified in the property.
This property is not supported when is `true`.
The property depends on the Layered Windows API. For more information, see [Layered Windows](/windows/win32/winmsg/window-features#layered-windows).
## Examples
The following example demonstrates how to create a form that is displayed with an opacity level of 75 percent. It creates a new form that is positioned in the center of the screen with an property set to change the opacity level of the form. The example also sets the property to provide a larger sized form than the default size of the form.
This example assumes that the `CreateMyOpaqueForm` method is called from another form in an event handler or other method.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.Opacity/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Opacity/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Opacity/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.Runtime.CompilerServices.Nullable(1)]
[<System.Runtime.CompilerServices.Nullable(1)>]
System.Windows.Forms.Form[]
Gets an array of objects that represent all forms that are owned by this form.
A array that represents the owned forms for this form.
method. The form assigned to the owner form will remain owned until the method is called. You can also make a form owned by another by setting the property with a reference to its owner form.
When a form is owned by another form, it is closed or hidden with the owner form. For example, consider a form named `Form2` that is owned by a form named `Form1`. If `Form1` is closed or minimized, `Form2` is also closed or hidden. Owned forms are also never displayed behind their owner form. You can use owned forms for windows such as find and replace windows, which should not be displayed behind the owner form when the owner form is selected.
> [!NOTE]
> If the form is a multiple-document interface (MDI) parent form, this property will return all forms that are displayed with the exception of any MDI child forms that are currently open. To obtain the MDI child forms opened in an MDI parent form, use the property.
## Examples
The following example demonstrates how to use the property to modify all forms owned by the owner form. The first method in the example adds forms to the array of owned forms associated with the owned form. The second method loops through all owned forms and changes the caption. This example requires that both methods are called by an event or other method of a form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.OwnedForms/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/OwnedForms/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/OwnedForms/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Windows.Forms.Form
Gets or sets the form that owns this form.
A that represents the form that is the owner of this form.
property a reference to the form that will be the owner.
When a form is owned by another form, it is closed or hidden with the owner form. For example, consider a form named `Form2` that is owned by a form named `Form1`. If `Form1` is closed or minimized, `Form2` is also closed or hidden. Owned forms are also never displayed behind their owner form. You can use owned forms for windows such as find and replace windows, which should not disappear when the owner form is selected. To determine the forms that are owned by a parent form, use the property.
]]>
A top-level window cannot have an owner.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Boolean
A , passed by reference, that represents the Win32 message to process.
One of the values that represents the key to process.
Processes a command key.
if the keystroke was processed and consumed by the control; otherwise, to allow further processing.
method overrides the base implementation to provide additional handling of main menu command keys and MDI accelerators.
For information about keyboard input, see [Keyboard Input in a Windows Forms Application](/dotnet/desktop/winforms/keyboard-input-in-a-windows-forms-application).
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Boolean
The character to process.
Processes a dialog character.
if the character was processed by the control; otherwise, .
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Boolean
One of the values that represents the key to process.
Processes a dialog box key.
if the keystroke was processed and consumed by the control; otherwise, to allow further processing.
method overrides the base implementation to provide additional handling of the RETURN and ESCAPE keys in dialog boxes. The method performs no processing on keystrokes that include the ALT or CONTROL modifiers.
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Boolean
A , passed by reference, that represents the window message to process.
Previews a keyboard message.
if the message was processed by the control; otherwise, .
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Boolean
The character to process.
Processes a mnemonic character.
if the character was processed as a mnemonic by the control; otherwise, .
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Boolean
to cycle forward through the controls in the ContainerControl; otherwise, .
Selects the next available control and makes it the active control.
if a control is selected; otherwise, .
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
A representing the form to remove from the list of owned forms for this form.
Removes an owned form from this form.
method is called. In addition to removing the owned form from the list of owned form, this method also sets the owner form to `null`.
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when a form enters resizing mode.
event is raised when the user begins to resize a form, typically by clicking and dragging one of the borders or the sizing grip located on the lower-right corner of the form. This action puts the form into a modal sizing loop until the resize operation is completed. Typically, the following set of events occurs during a resize operation:
1. A single event occurs as the form enters resizing mode.
2. Zero or more pairs of and events occur as the form's is modified.
3. A single event occurs as the form exits resizing mode.
> [!NOTE]
> Just clicking without dragging on a border or resizing grip will generate the and events without any intermediate and event pairs.
The and pair of events is also raised when the user moves the form, typically by clicking and dragging on the caption bar. These events are not generated by programmatic manipulation of the form, for example by changing the or properties.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet404":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet404":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs when a form exits resizing mode.
event is raised when the user finishes resizing a form, typically by dragging one of the borders or the sizing grip located on the lower-right corner of the form, and then releasing it. For more information about the resizing operation, see the event.
The event is also generated after the user moves a form, typically by clicking and dragging on the caption bar. This event is not generated by programmatic manipulation of the form, for example by changing the or properties.
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet405":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet405":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
System.Drawing.Rectangle
Gets the location and size of the form in its normal window state.
A that contains the location and size of the form in the normal window state.
property to track the user's window size and position preferences for the form in its normal window state. You should track both the value of the and properties when tracking the user's window preferences.
> [!NOTE]
> The value of the property is valid only when the property of the class is not equal to .
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(false)]
[<System.ComponentModel.DefaultValue(false)>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Boolean
Gets or sets a value indicating whether right-to-left mirror placement is turned on.
if right-to-left mirror placement is turned on; otherwise, for standard child control placement. The default is .
property is primarily useful for developing world-ready forms for worldwide audiences. Many forms are designed so that controls are laid out on a form in a left-to-right fashion. These forms are compatible with languages that follow this writing direction. However, when you display the same forms to users of right-to-left languages, it is often preferable to reverse the order of the controls on the form. If both the and properties are `true`, mirroring will be turned on for the form, and control placement and text flow will be right-to-left.
Unlike , does not inherit. If you want it to take effect for child controls, you must set it on each child control that you want mirrored.
Owner draw is not supported when is set to `Yes`. The owner draw events will still occur, but the behavior of any code you author in these events is not defined. Additionally, , , , and the painting events are not supported.
The and properties cause the following Windows API window styles to be set:
- When is set to `Yes` and is set to `true`, Windows Forms sets the `WS_EX_LAYOUTRTL` window style, and removes the `WS_EX_RIGHT` and `WS_EX_RTLREADING` styles.
- When is set to `Yes` but is set to `No`, Windows Forms sets the `WS_EX_RIGHT` and `WS_EX_RTLREADING` window styles.
Changing the value of this property raises the event.
For more information about globalization issues, see [Best Practices for Developing World-Ready Applications](/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps).
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs after the value of the property changes.
and properties are typically used in developing World-Ready applications.
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet402":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet402":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The factor by which the height and width of the control are scaled.
A value that specifies the bounds of the control to use when defining its size and position.
Scales the location, size, padding, and margin of a control.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
System.Void
Percentage to scale the form horizontally.
Percentage to scale the form vertically.
Performs scaling of the form.
To be added.
Method
System.Windows.Forms
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
The scale factor to be applied on the width of the property being scaled.
The scale factor to be applied on the height of the property being scaled.
to resize the Form along with properties being scaled; otherwise, .
Scales the size of the form's and properties with the scale factor provided.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
If set to true that the active control is changed.
If directed is true, then this controls the direction in which focus is moved. If this is , then the next control is selected; otherwise, the previous control is selected.
Selects this form, and optionally selects the next or previous control.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The new property value of the control.
The new property value of the control.
The new property value of the control.
The new property value of the control.
A bitwise combination of the values.
Performs the work of setting the specified bounds of this control.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
Requested width of the client region.
Requested height of the client region.
Sets the client size of the form. This will adjust the bounds of the form to make the client size the requested size.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
The x-coordinate of the form's location.
The y-coordinate of the form's location.
The width of the form.
The height of the form.
Sets the bounds of the form in desktop coordinates.
method. To run this example, paste the following code in a form that contains a button named `Button2`. Ensure all events are associated with their event handlers.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FormExample/CPP/form1.cpp" id="Snippet2":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/MaximumSize/form1.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/MaximumSize/form1.vb" id="Snippet2":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
The x-coordinate of the form's location.
The y-coordinate of the form's location.
Sets the location of the form in desktop coordinates.
method to position multiple-document interface (MDI) child forms.
## Examples
The following example demonstrates how to use the , and members. To run the example, paste the following code in a form called `Form1` containing a button called `Button1` and two `Label` controls called `Label1` and `Label2`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FormsActivate/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Activate/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Activate/form1.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
to make the control visible; otherwise, .
Sets the control to the specified visible state.
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
Any object that implements and represents the top-level window that will own this form.
Shows the form with the specified owner to the user.
property of the form is set to `owner`. The non-modal form can use the property to get information about the owning form. Calling this method is identical to setting the property of the non-modal and then calling the method.
Showing the form is equivalent to setting the property to `true`. After the method is called, the property returns a value of `true` until the method is called.
]]>
The form being shown is already visible.
-or-
The form specified in the parameter is the same as the form being shown.
-or-
The form being shown is disabled.
-or-
The form being shown is not a top-level window.
-or-
The form being shown as a dialog box is already a modal form.
-or-
The current process is not running in user interactive mode (for more information, see ).
The owner window is trying to set itself as its own owner.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Threading.Tasks.Task
[System.Runtime.CompilerServices.Nullable(2)]
[<System.Runtime.CompilerServices.Nullable(2)>]
The optional owner window that implements .
Displays the form asynchronously, by setting its property to .
A that completes when the form is closed or disposed.
This method makes the form visible by setting the property to .
This method immediately returns, even if the form is large and takes a long time to be set up.
The task will complete when the form is closed or disposed.
If the owner window is provided, it ensures that the owner is topmost and sets the owner for the form.
This method also performs several checks to prevent invalid operations, such as trying to display a disabled form, attempting to display the form when
it is not a top-level window, or setting the form as its own owner.
If the operating system is in a non-interactive mode, this method will throw an .
If the form is already displayed asynchronously, an will be thrown.
An will also occur if no could be retrieved or installed.
There is no need to marshal the call to the UI thread manually if the call originates from a different thread than the UI-Thread. This is handled automatically.
The form is already visible.
-or-
The form is disabled.
-or-
The form is not a top-level form.
-or-
The form is trying to set itself as its own owner.
-or-
The form is already displayed asynchronously.
-or-
No could be retrieved or installed.
-or-
The operating system is in a non-interactive mode.
The owner window is trying to set itself as its own owner.
Shows the form as a modal dialog box.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.DialogResult
Shows the form as a modal dialog box.
One of the values.
enumeration by assigning it to the property of a on the form or by setting the property of the form in code. This value is then returned by this method. You can use this return value to determine how to process the actions that occurred in the dialog box. For example, if the dialog box was closed and returned the `DialogResult.Cancel` value through this method, you could prevent code following the call to from executing.
When a form is displayed as a modal dialog box, clicking the **Close** button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the property to be set to `DialogResult.Cancel`. Unlike non-modal forms, the method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is hidden instead of closed, you must call the method of the form when the form is no longer needed by your application.
This version of the method does not specify a form or control as its owner. When this version is called, the currently active window is made the owner of the dialog box. If you want to specify a specific owner, use the other version of this method.
## Examples
The following example displays a form as a modal dialog box and evaluates the return value of the dialog box before determining whether to read the value of a control on the dialog box form. This example requires that a named `testDialog` is created and that it contains a control named `TextBox1`. Furthermore, the example requires that code in this example is contained and called from a different in order to display `testDialog` as a modal dialog box. The example uses the version of that specifies an owner for the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.ShowDialog Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ShowDialog/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ShowDialog/source.vb" id="Snippet1":::
]]>
The form being shown is already visible.
-or-
The form being shown is disabled.
-or-
The form being shown is not a top-level window.
-or-
The form being shown as a dialog box is already a modal form.
-or-
The current process is not running in user interactive mode (for more information, see ).
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Windows.Forms.DialogResult
Any object that implements that represents the top-level window that will own the modal dialog box.
Shows the form as a modal dialog box with the specified owner.
One of the values.
by assigning it to the property of a on the form or by setting the property of the form in code. This value is then returned by this method. You can use this return value to determine how to process the actions that occurred in the dialog box. For example, if the dialog box was closed and returned the `DialogResult.Cancel` value through this method, you could prevent code following the call to from executing.
When a form is displayed as a modal dialog box, clicking the **Close** button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the property to be set to `DialogResult.Cancel`. Unlike modeless forms, the method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is hidden instead of closed, you must call the method of the form when the form is no longer needed by your application.
This version of the method allows you to specify a specific form that will own the dialog box that is shown.
## Examples
The following example displays a form as a modal dialog box and evaluates the return value of the dialog box before determining whether to read the value of a control on the dialog box form. This example requires that a named `Form2` is created and that it contains a control named `TextBox1`. The example uses the version of that specifies an owner for the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.ShowDialog Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ShowDialog/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ShowDialog/source.vb" id="Snippet1":::
]]>
The form specified in the parameter is the same as the form being shown.
The form being shown is already visible.
-or-
The form being shown is disabled.
-or-
The form being shown is not a top-level window.
-or-
The form being shown as a dialog box is already a modal form.
-or-
The current process is not running in user interactive mode (for more information, see ).
Shows the form as a modal dialog box asynchronously.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Threading.Tasks.Task<System.Windows.Forms.DialogResult>
Shows the form as a modal dialog box asynchronously.
A representing the outcome of the dialog. The task completes when the form is closed or disposed.
The task will complete when the form is closed or disposed.
This method immediately returns, even if the form is large and takes a long time to be set up.
If the form is already displayed asynchronously by , an will be thrown.
An will also occur if no could be retrieved or installed.
There is no need to marshal the call to the UI thread manually if the call originates from a different thread. This is handled automatically.
Any exceptions that occur will be automatically propagated to the calling thread.
The form is already displayed asynchronously.
-or-
No could be retrieved or installed.
Method
System.Windows.Forms
9.0.0.0
10.0.0.0
11.0.0.0
[System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
System.Threading.Tasks.Task<System.Windows.Forms.DialogResult>
Any object that implements that represents the top-level window that will own the modal dialog box.
Shows the form as a modal dialog box with the specified owner asynchronously.
A representing the outcome of the dialog. The task completes when the form is closed or disposed.
The task will complete when the form is closed or disposed.
This method immediately returns, even if the form is large and takes a long time to be set up.
If the form is already displayed asynchronously by , an will be thrown.
An will also occur if no could be retrieved or installed.
There is no need to marshal the call to the UI thread manually if the call originates from a different thread. This is handled automatically.
Any exceptions that occur will be automatically propagated to the calling thread.
The form is already displayed asynchronously.
-or-
No could be retrieved or installed.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
System.Boolean
Gets or sets a value indicating whether an icon is displayed in the caption bar of the form.
if the form displays an icon in the caption bar; otherwise, . The default is .
property contains a value that indicates whether the form's is displayed in the caption bar of the form. If the property is `false`, both the icon and control box will be suppressed.
If is `false` when the primary form is shown, a generic icon will be displayed in the taskbar button for the application.
This property has no effect if is set to . In that case, the form does not display an icon.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
System.Boolean
Gets or sets a value indicating whether the form is displayed in the Windows taskbar.
to display the form in the Windows taskbar at run time; otherwise, . The default is .
style. Setting the style does not alone guarantee that a window will not appear in the taskbar.
## Examples
The following example demonstrates how to use the property to make a dialog box that is not displayed in the Windows taskbar.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.ShowInTaskbar/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/ShowInTaskbar/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/ShowInTaskbar/form1.vb" id="Snippet1":::
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.EventHandler
Occurs whenever the form is first displayed.
event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting will not raise this event. For more information about the order of events of a form, see [Order of Events in Windows Forms](/dotnet/desktop/winforms/order-of-events-in-windows-forms).
For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/).
## Examples
The following example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline .
To run the example code, paste it into a project that contains an instance of type named `Form1`. Then ensure that the event handler is associated with the event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet403":::
:::code language="vb" source="~/snippets/visualbasic/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.vb" id="Snippet403":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
System.Boolean
Gets a value indicating whether the window will be activated when it is shown.
if the window will not be activated when it is shown; otherwise, . The default is .
in your own form, and programming it to return `true`.
If your non-activated window needs to use UI controls, you should consider using the controls, such as . These controls are windowless, and will not cause a window to activate when they are selected.
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.Localizable(false)]
[<System.ComponentModel.Localizable(false)>]
System.Drawing.Size
Gets or sets the size of the form.
A that represents the size of the form.
and properties individually. If you want to set the size and location of a form, you can use the property to size and locate the form based on desktop coordinates or use the property of the class to set the size and location of the form based on screen coordinates.
> [!NOTE]
> The maximum value of this property is limited by the resolution of the screen on which the form runs. The value cannot be greater than 12 pixels over each screen dimension (horizontal + 12 and vertical + 12).
> [!NOTE]
> On Pocket PC devices, you can create a resizable window by setting to `None` and removing any control. On SmartPhone devices, you can never resize a - it will always fill the entire screen.
## Examples
The following example demonstrates how to create a form that is displayed with an opacity level of 75 percent. The example code creates a new form that is positioned in the center of the screen with an property set to change the opacity level of the form. The example code also sets the property to provide a larger sized form than the default size of the form. This example requires that the method defined in this example is called from another form in an event handler or other method.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.Opacity/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Opacity/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Opacity/form1.vb" id="Snippet1":::
]]>
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(System.Windows.Forms.SizeGripStyle.Auto)]
[<System.ComponentModel.DefaultValue(System.Windows.Forms.SizeGripStyle.Auto)>]
System.Windows.Forms.SizeGripStyle
Gets or sets the style of the size grip to display in the lower-right corner of the form.
A that represents the style of the size grip to display. The default is
property.
## Examples
The following example demonstrates how to hide the size grip for a when the is not resizable.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.SizeGripStyle/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/SizeGripStyle/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/SizeGripStyle/form1.vb" id="Snippet1":::
]]>
The value specified is outside the range of valid values.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(System.Windows.Forms.FormStartPosition.WindowsDefaultLocation)]
[<System.ComponentModel.DefaultValue(System.Windows.Forms.FormStartPosition.WindowsDefaultLocation)>]
[System.ComponentModel.Localizable(true)]
[<System.ComponentModel.Localizable(true)>]
System.Windows.Forms.FormStartPosition
Gets or sets the starting position of the form at run time.
A that represents the starting position of the form.
property or use the default location specified by Windows. You can also position the form to display in the center of the screen or in the center of its parent form for forms such as multiple-document interface (MDI) child forms.
This property should be set before the form is shown. You can set this property before you call the or method or in your form's constructor.
## Examples
The following example creates a new instance of a and calls the method to display the form as a dialog box. The example sets the , , , and properties to change the appearance and functionality of the form to a dialog box. The example also uses the method of the form's collection to add two controls. The example uses the property to display a help button in the caption bar of the dialog box.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.StartPosition Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/StartPosition/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/StartPosition/source.vb" id="Snippet1":::
]]>
The value specified is outside the range of valid values.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
System.Int32
Gets or sets the tab order of the control within its container.
An containing the index of the control within the set of controls within its container that is included in the tab order.
property does nothing.
]]>
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
System.EventHandler
Occurs when the value of the property changes.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DefaultValue(true)]
[<System.ComponentModel.DefaultValue(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
[System.Runtime.InteropServices.DispId(-516)]
[<System.Runtime.InteropServices.DispId(-516)>]
System.Boolean
Gets or sets a value indicating whether the user can give the focus to this control using the TAB key.
if the user can give the focus to the control using the TAB key; otherwise, . The default is .
To be added.
Event
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
System.EventHandler
Occurs when the property changes.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.SettingsBindable(true)]
[<System.ComponentModel.SettingsBindable(true)>]
[System.Runtime.CompilerServices.Nullable(1)]
[<System.Runtime.CompilerServices.Nullable(1)>]
System.String
Gets or sets the text associated with this control.
The text associated with this control.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(false)]
[<System.ComponentModel.Browsable(false)>]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Boolean
Gets or sets a value indicating whether to display the form as a top-level window.
to display the form as a top-level window; otherwise, . The default is .
property to determine if a form is displayed as a modal form. If it is not the and properties are changed to make the form non-top-level form with a tool window border.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.Modal/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Modal/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/Modal/form1.vb" id="Snippet1":::
]]>
A Multiple-document interface (MDI) parent form must be a top-level window.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(false)]
[<System.ComponentModel.DefaultValue(false)>]
System.Boolean
Gets or sets a value indicating whether the form should be displayed as a topmost form.
to display the form as a topmost form; otherwise, . The default is .
property, to better demonstrate the abilities of the topmost form. The second form, named `topMostForm`, sets the property to `true` to display the form as a topmost form. When this code is run, clicking on the maximized form will not cause the topmost form to be displayed below the maximized form. The example requires that the method defined in the example is called from another form.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Form.TopMost/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/TopMost/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/TopMost/form1.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.String
Gets a string representing the current instance of the form.
A string consisting of the fully qualified name of the form object's class, with the property of the form appended to the end. For example, if the form is derived from the class MyForm in the MyNamespace namespace, and the property is set to Hello, World, this method will return MyNamespace.MyForm, Text: Hello, World.
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Drawing.Color
Gets or sets the color that will represent transparent areas of the form.
A that represents the color to display transparently on the form.
property is assigned a , the areas of the form that have the same will be displayed transparently. Any mouse actions, such as the click of the mouse, that are performed on the transparent areas of the form will be transferred to the windows below the transparent area. For example, if the client region of a form is made transparent, clicking the mouse on that area would send the event notification of the click to any window that is below it. If the color assigned to the property is the same as any controls on the form, they also will be displayed transparently. For example, if you have a control on a form that has its property set to `SystemColors.Control`, the control will be displayed transparently unless the property of the control is changed to a different color.
This property is not supported when is `true`.
## Examples
The following example creates a window that has a transparent client region regardless of background color of the form. This example requires that the example method is defined within a form class.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Form.TransparencyKey Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/TransparencyKey/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Windows.Forms/Form/TransparencyKey/source.vb" id="Snippet1":::
]]>
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
System.Void
Updates which button is the default button.
method determines which button on the form raises its Click event when the user presses ENTER, according to the following priority:
1. If the property implements the interface, that control is the default button.
2. The property is the default button.
]]>
Validates all selectable child controls in the form.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.Boolean
Causes all of the child controls within a control that support validation to validate their data.
if all of the children validated successfully; otherwise, . If called from the or event handlers, this method will always return .
To be added.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.Browsable(true)]
[<System.ComponentModel.Browsable(true)>]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>]
System.Boolean
Places restrictions on which controls have their event raised.
Causes all of the child controls within a control that support validation to validate their data.
if all of the children validated successfully; otherwise, . If called from the or event handlers, this method will always return .
To be added.
Property
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.DefaultValue(System.Windows.Forms.FormWindowState.Normal)]
[<System.ComponentModel.DefaultValue(System.Windows.Forms.FormWindowState.Normal)>]
System.Windows.Forms.FormWindowState
Gets or sets a value that indicates whether form is minimized, maximized, or normal.
A that represents whether form is minimized, maximized, or normal. The default is .
property is always set to `FormWindowState.Normal`, regardless of its initial setting. This is reflected in the , , , and property settings. If a form is hidden after it has been shown, these properties reflect the previous state until the form is shown again, regardless of any changes made to the property.
## Examples
The following example demonstrates how to set the to maximized. The code is called from the event handler after the form has been created.
```csharp
private void Form1_Shown(object sender, EventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
```
```vb
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs)
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
End Sub
```
]]>
The value specified is outside the range of valid values.
Method
System.Windows.Forms
4.0.0.0
5.0.0.0
6.0.0.0
7.0.0.0
8.0.0.0
9.0.0.0
10.0.0.0
11.0.0.0
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)>]
System.Void
The Windows to process.
Processes Windows messages.
To be added.