Form.ClientSize Form.ClientSize Form.ClientSize Form.ClientSize Property

定义

获取或设置窗体工作区的大小。Gets or sets the size of the client area of the form.

public:
 property System::Drawing::Size ClientSize { System::Drawing::Size get(); void set(System::Drawing::Size value); };
public System.Drawing.Size ClientSize { get; set; }
member this.ClientSize : System.Drawing.Size with get, set
Public Property ClientSize As Size

属性值

Size,表示窗体工作区的大小。A Size that represents the size of the form's client area.

示例

下面的代码示例创建的事件处理程序Resize窗体的事件。The following code example creates an event handler for the Resize event of a form. 事件处理程序使用ClientSize要使窗体的属性Button控件命名为button1填充窗体的整个工作区。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.

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

注解

窗体的工作区的大小为窗体不包括边框和标题栏的大小。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. 若要获取整个窗体大小,请使用Size属性,或使用单独的属性HeightWidthTo get the size of the entire form, use the Size property or use the individual properties Height and Width.

备注

当前不能绑定到使用应用程序设置此属性。You cannot currently bind to this property using application settings. 应用程序设置的详细信息,请参阅应用程序设置概述For more information on application settings, see Application Settings Overview.

适用于

另请参阅