Share via


Control.DefaultSize 属性

获取控件的默认大小。

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

语法

声明
Protected Overridable ReadOnly Property DefaultSize As Size
用法
Dim value As Size

value = Me.DefaultSize
protected virtual Size DefaultSize { get; }
protected:
virtual property Size DefaultSize {
    Size get ();
}
/** @property */
protected Size get_DefaultSize ()
protected function get DefaultSize () : Size

属性值

控件的默认 Size

备注

DefaultSize 属性表示在初次创建控件时控件的 Size。可以通过设置控件的 Size 属性值来调整控件大小。

提示

若要保持性能更佳,请不要在控件的构造函数中设置控件的 Size。首选方法是重写 DefaultSize 属性。

给继承者的说明 当在派生类中重写 DefaultSize 属性时,最好返回带有所需维数的 Size,而不是重写所有实现。

示例

下面的代码示例重写 DefaultSize 属性,并使窗体的默认大小为 500 像素的正方形。

Protected Overrides ReadOnly Property DefaultSize() As Size
   Get
      ' Set the default size of
      ' the form to 500 pixels square. 
      Return New Size(500, 500)
   End Get
End Property
protected override Size DefaultSize
{
   get
   {
      // Set the default size of
      // the form to 500 pixels square.
      return new Size(500,500);
   }
}
protected:
   property System::Drawing::Size DefaultSize 
   {
      virtual System::Drawing::Size get() override
      {
         // Set the default size of
         // the form to 500 pixels square.
         return System::Drawing::Size( 500, 500 );
      }
   }
/** @property 
 */
protected Size get_DefaultSize()
{
    // Set the default size of
    // the form to 500 pixels square.
    return new Size(500, 500);
}

平台

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

请参见

参考

Control 类
Control 成员
System.Windows.Forms 命名空间
Control.Size
Size