Export (0) Print
Expand All

Form.ClientSize Property

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

[Visual Basic]
Public Shadows Property ClientSize As Size
[C#]
public new Size ClientSize {get; set;}
[C++]
public: __property Size get_ClientSize();
public: __property void set_ClientSize(Size);
[JScript]
public hide function get ClientSize() : Size;
public hide function set ClientSize(Size);

Property Value

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

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.

Example

[Visual Basic, C#, C++] 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.

[Visual Basic] 
Private Sub MyForm_Resize(sender As Object, e As EventHandler)
    ' Set the size of button1 to the size of the client area of the form.
    button1.Size = Me.ClientSize
End Sub 'MyForm_Resize

[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;
 }
    

[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;
 }
    

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Form Class | Form Members | System.Windows.Forms Namespace | Size | Height | Width

Show:
© 2014 Microsoft