Form.ClientSize Property

Definition

Gets or sets the size of the client area of the form.

C#
public System.Drawing.Size ClientSize { get; set; }

Property Value

A Size that represents the size of the form's client area.

Examples

The following example creates an event handler for the Resize event of a form. The event handler uses the ClientSize property of the form to make a Button control named button1 fill the entire client area of the form.

C#
private void MyForm_Resize (Object sender, EventHandler e)
 {
    // Set the size of button1 to the size of the client area of the form.
    button1.Size = this.ClientSize;
 }

Remarks

The size of the client area of the form is the size of the form excluding the borders and the title bar. The client area of a form is the area within a form where controls can be placed. You can use this property to get the proper dimensions when performing graphics operations or when sizing and positioning controls on the form. To get the size of the entire form, use the Size property or use the individual properties Height and Width.

Note

You cannot currently bind to this property using application settings. For more information on application settings, see Application Settings Overview.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also