Share via


Form.ClientSize 属性

获取或设置窗体工作区的大小。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
<LocalizableAttribute(True)> _
Public Property ClientSize As Size
用法
Dim instance As Form
Dim value As Size

value = instance.ClientSize

instance.ClientSize = value
[LocalizableAttribute(true)] 
public Size ClientSize { get; set; }
[LocalizableAttribute(true)] 
public:
property Size ClientSize {
    Size get ();
    void set (Size value);
}
/** @property */
public Size get_ClientSize ()

/** @property */
public void set_ClientSize (Size value)
public function get ClientSize () : Size

public function set ClientSize (value : Size)

属性值

Size,表示窗体工作区的大小。

备注

窗体工作区的大小是除边框和标题栏外窗体的大小。窗体的工作区是窗体内可放置控件的区域。当执行图形操作或调整窗体上控件的大小和位置时,可以使用此属性获取正确的尺寸。若要获取整个窗体的大小,请使用 Size 属性或使用单个属性 HeightWidth

示例

下面的代码示例为窗体的 Resize 事件创建事件处理程序。该事件处理程序使用窗体的 ClientSize 属性,使名为 button1Button 控件填充窗体的整个工作区。

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
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 void MyForm_Resize(Object sender, EventHandler e)
{
    // Set the size of button1 to the size of the client area of the form.
    button1.set_Size(this.get_ClientSize());
} //MyForm_Resize

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Form 类
Form 成员
System.Windows.Forms 命名空间
Size
Control.Height 属性
Control.Width 属性