Form.ClientSize 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置窗体工作区的大小。
public:
property System::Drawing::Size ClientSize { System::Drawing::Size get(); void set(System::Drawing::Size value); };
C#
public System.Drawing.Size ClientSize { get; set; }
member this.ClientSize : System.Drawing.Size with get, set
Public Property ClientSize As Size
Size,表示窗体工作区的大小。
以下示例为 Resize 窗体的 事件创建事件处理程序。 事件处理程序使用 ClientSize 窗体的 属性使 Button 名为 的 button1
控件填充窗体的整个工作区。
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;
}
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
窗体工作区的大小是窗体的大小,不包括边框和标题栏。 窗体的工作区是窗体内可以放置控件的区域。 当执行图形操作或在窗体上调整控件的大小和位置时,可以使用此属性获取正确的尺寸。 若要获取整个窗体的大小,请使用 Size 属性或使用单个属性 Height 和 Width。
备注
当前无法使用应用程序设置绑定到此属性。 有关应用程序设置的详细信息,请参阅 应用程序设置概述。
产品 | 版本 |
---|---|
.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, 10 |