Gets or sets the size of the form.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
This property allows you to set both the height and width (in pixels) of the form at the same time instead of setting the Height and Width properties individually. If you want to set the size and location of a form, you can use the DesktopBounds property to size and locate the form based on desktop coordinates or use the Bounds property of the Control class to set the size and location of the form based on screen coordinates.
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).
The following code 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 Opacity 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.
Private Sub CreateMyOpaqueForm() ' Create a new form. Dim form2 As New Form() ' Set the text displayed in the caption. form2.Text = "My Form" ' Set the opacity to 75%. form2.Opacity = 0.75 ' Size the form to be 300 pixels in height and width. form2.Size = New Size(300, 300) ' Display the form in the center of the screen. form2.StartPosition = FormStartPosition.CenterScreen ' Display the form as a modal dialog box. form2.ShowDialog() End Sub
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.