Control.DefaultSize 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會得到預設大小的控制器。
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
屬性值
控制的預設 Size 。
範例
以下程式碼範例覆寫了該屬性, DefaultSize 並將預設的 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 );
}
}
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 你可以透過設定屬性 Size 值來調整控制項的大小。
備註
為了維持更好的效能,不要在其建構子中設定 的 Size 控制項。 首選方法是覆寫該 DefaultSize 屬性。
備註
在 Windows Server 2003 系統中,a Form 的大小受限於螢幕的最大像素寬度與高度。
給繼承者的注意事項
在導出類別中覆寫該 DefaultSize 性質時,最好回傳以所需維度的 a Size ,而非覆蓋所有實作。