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

注解

窗体工作区的大小是不包括边框和标题栏的窗体的大小。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.

适用于

另请参阅