Control.DefaultSize Control.DefaultSize Control.DefaultSize Control.DefaultSize Property

定義

取得控制項的預設大小。Gets the default size of the control.

protected:
 virtual property System::Drawing::Size DefaultSize { System::Drawing::Size get(); };
protected virtual System.Drawing.Size DefaultSize { get; }
member this.DefaultSize : System.Drawing.Size
Protected Overridable ReadOnly Property DefaultSize As Size

屬性值

控制項的預設 SizeThe default Size of the control.

範例

下列程式碼範例會覆DefaultSize寫屬性,並將預設大小設為500圖元的正方形。The following code example overrides the DefaultSize property, and makes the default size of the form 500 pixels square.

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 );
      }
   }
protected override Size DefaultSize
{
   get
   {
      // Set the default size of
      // the form to 500 pixels square.
      return new Size(500,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

備註

DefaultSize 屬性Size代表控制項最初建立時的。The DefaultSize property represents the Size of the control when it is initially created. 您可以藉由設定控制項的屬性值來調整Size其大小。You can adjust the size of the control by setting its Size property value.

注意

若要維持較佳Size的效能,請不要在其「函式」中設定控制項的。To maintain better performance, do not set the Size of a control in its constructor. 慣用的方法是覆寫DefaultSize屬性。The preferred method is to override the DefaultSize property.

注意

在 Windows Server 2003 系統上,的大小Form受限於監視的最大圖元寬度和高度。On Windows Server 2003 systems, the size of a Form is restricted by the maximum pixel width and height of the monitor.

給繼承者的注意事項

覆寫衍生DefaultSize類別中的屬性時,最好Size是傳回具有所需維度的,而不是覆寫所有的實作為。When overriding the DefaultSize property in a derived class, it is preferable to return a Size with the desired dimensions rather than to override all the implementation.

適用於

另請參閱