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 屬性的 、 Width 或 或 X Y 屬性 Location 可以使用控制項目前實例的參考傳入。 不過,傳入的所有值都會接受並套用至 控制項。

參數 boundsSpecified 代表應用程式變更之控制項 Bounds 的專案。 例如,如果您變更 Size 控制項的 ,參數 boundsSpecified 值就是 Size 的值 BoundsSpecified 。 不過,如果 Size 已調整 以回應 Dock 所設定的屬性,參數 boundsSpecified 值就是 None 的值 BoundsSpecified

注意

在 Windows Server 2003 系統上,的大小 Form 受限於監視器的最大圖元寬度和高度。

給繼承者的注意事項

在衍生類別中覆 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 寫時,請務必呼叫基類 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 的 方法來強制控制項的界限變更。 衍生類別可以將大小限制新增至 SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified) 方法。

適用於

另請參閱