共用方式為


Control.SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 方法

定義

負責設定此控制範圍的工作。

protected:
 virtual void SetBoundsCore(int x, int y, int width, int height, System::Windows::Forms::BoundsSpecified specified);
protected virtual void SetBoundsCore(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);
abstract member SetBoundsCore : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
override this.SetBoundsCore : int * int * int * int * System.Windows.Forms.BoundsSpecified -> unit
Protected Overridable Sub SetBoundsCore (x As Integer, y As Integer, width As Integer, height As Integer, specified As BoundsSpecified)

參數

x
Int32

Left控制的新財產價值。

y
Int32

Top控制的新財產價值。

width
Int32

Width控制的新財產價值。

height
Int32

Height控制的新財產價值。

specified
BoundsSpecified

這是數值的位元組合 BoundsSpecified

範例

以下程式碼範例覆寫該 SetBoundsCore 方法,以確保控制項大小不變。 這個例子要求你有一個類別,該類別是直接或間接由該 Control 類別衍生而來。

protected:
   virtual void SetBoundsCore( int x, int y, int width, int height, BoundsSpecified specified ) override
   {
      // Set a fixed height and width for the control.
      UserControl::SetBoundsCore( x, y, 150, 75, specified );
   }
protected override void SetBoundsCore(int x, int y, 
   int width, int height, BoundsSpecified specified)
{
   // Set a fixed height and width for the control.
   base.SetBoundsCore(x, y, 150, 75, specified);
}
Protected Overrides Sub SetBoundsCore(x As Integer, _
  y As Integer, width As Integer, _
  height As Integer, specified As BoundsSpecified)
   ' Set a fixed height and width for the control.
   MyBase.SetBoundsCore(x, y, 150, 75, specified)
End Sub

備註

通常,對應於未包含在 specified 參數範圍內的參數會以目前的值傳遞。 例如,Height屬性的 、 WidthX 屬性YLocation可以參考當前控制項實例。 然而,所有輸入的數值都會被尊重並套用到控制權上。

參數 boundsSpecified 代表你的應用程式所更改的控制項 Bounds 元素。 例如,若你改變控制項的參數 Size 值, boundsSpecified 參數值即為 SizeBoundsSpecified值。 然而,若根據所設定boundsSpecified的性質調整 DockSize參數值即為 NoneBoundsSpecified值。

備註

在 Windows Server 2003 系統中,a Form 的大小受限於螢幕的最大像素寬度與高度。

給繼承者的注意事項

在導出類別中覆 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 寫時,務必呼叫基底類別的方法 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) ,強制改變控制項的界限。 導出類別可以為方法增加大小限制 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)

適用於

另請參閱