Control.SetBounds メソッド

定義

コントロールの範囲を設定します。

オーバーロード

SetBounds(Int32, Int32, Int32, Int32)

コントロールの範囲を指定した位置とサイズに設定します。

SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

コントロールの指定した範囲を指定した位置とサイズに設定します。

SetBounds(Int32, Int32, Int32, Int32)

コントロールの範囲を指定した位置とサイズに設定します。

C#
public void SetBounds (int x, int y, int width, int height);

パラメーター

x
Int32

コントロールの新しい Left プロパティ値。

y
Int32

コントロールの新しい Top プロパティ値。

width
Int32

コントロールの新しい Width プロパティ値。

height
Int32

コントロールの新しい Height プロパティ値。

こちらもご覧ください

適用対象

.NET Framework 4.8.1 およびその他のバージョン
製品 バージョン
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

コントロールの指定した範囲を指定した位置とサイズに設定します。

C#
public void SetBounds (int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);

パラメーター

x
Int32

コントロールの新しい Left プロパティ値。

y
Int32

コントロールの新しい Top プロパティ値。

width
Int32

コントロールの新しい Width プロパティ値。

height
Int32

コントロールの新しい Height プロパティ値。

specified
BoundsSpecified

BoundsSpecified 値のビットごとの組み合わせ。 指定されていないパラメーターについては、現在の値が使用されます。

次のコード例では、 イベントの画面Layoutに を中央Formに置きます。 これにより、ユーザーがフォームのサイズを変更すると、フォームの中央が維持されます。 この例では、コントロールを作成している Form 必要があります。

C#
private void MyForm_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{
   // Center the Form on the user's screen everytime it requires a Layout.
   this.SetBounds((Screen.GetBounds(this).Width/2) - (this.Width/2),
       (Screen.GetBounds(this).Height/2) - (this.Height/2),
       this.Width, this.Height, BoundsSpecified.Location);	
}

こちらもご覧ください

適用対象

.NET Framework 4.8.1 およびその他のバージョン
製品 バージョン
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9