.NET Framework クラス ライブラリ
Control.SetBounds メソッド (Int32, Int32, Int32, Int32, BoundsSpecified)
この記事は翻訳者によって翻訳されたものです。 このページおよび元の英語コンテンツを同時に表示させるには、[ライトウェイト] に切り替えます。
コントロールの指定した範囲を指定した位置とサイズに設定します。
アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)
構文
Visual Basic
Public Sub SetBounds ( _ x As Integer, _ y As Integer, _ width As Integer, _ height As Integer, _ specified As BoundsSpecified _ )
C#
public void SetBounds( int x, int y, int width, int height, BoundsSpecified specified )
Visual C++
public: void SetBounds( int x, int y, int width, int height, BoundsSpecified specified )
F#
member SetBounds : x:int * y:int * width:int * height:int * specified:BoundsSpecified -> unit
パラメーター
- x
- 型: System.Int32
コントロールの新しい Left プロパティ値。
- y
- 型: System.Int32
コントロールの新しい Top プロパティ値。
- width
- 型: System.Int32
コントロールの新しい Width プロパティ値。
- height
- 型: System.Int32
コントロールの新しい Height プロパティ値。
- specified
- 型: System.Windows.Forms.BoundsSpecified
BoundsSpecified 値のビットごとの組み合わせ。 指定されていないパラメーターについては、現在の値が使用されます。
例
Layout イベントで画面の中央に Form を配置するコード例を次に示します。 これにより、ユーザーがフォームのサイズを変更しても、フォームは中央に配置されます。 この例では、Form コントロールが既に作成されている必要があります。
Visual Basic
Private Sub MyForm_Layout(ByVal sender As Object, _ ByVal e As System.Windows.Forms.LayoutEventArgs) Handles MyBase.Layout ' Center the Form on the user's screen everytime it requires a Layout. Me.SetBounds((System.Windows.Forms.Screen.GetBounds(Me).Width / 2) - (Me.Width / 2), _ (System.Windows.Forms.Screen.GetBounds(Me).Height / 2) - (Me.Height / 2), _ Me.Width, Me.Height, System.Windows.Forms.BoundsSpecified.Location) End Sub
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); }
Visual 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、3.5、3.0、2.0、1.1、1.0.NET Framework Client Profile
サポート対象: 4、3.5 SP1プラットフォーム
Windows 7, Windows Vista SP1 以降, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core はサポート対象外), Windows Server 2008 R2 (SP1 以降で Server Core をサポート), Windows Server 2003 SP2
.NET Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
参照