Control.Layout イベント
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コントロールの子コントロールの位置を変更する必要があるときに発生します。
public:
event System::Windows::Forms::LayoutEventHandler ^ Layout;
public event System.Windows.Forms.LayoutEventHandler Layout;
public event System.Windows.Forms.LayoutEventHandler? Layout;
member this.Layout : System.Windows.Forms.LayoutEventHandler
Public Custom Event Layout As LayoutEventHandler
次のコード例では、 Form イベントの画面上に を中央に Layout 置きます。 これにより、ユーザーがフォームのサイズを変更すると、フォームの中央揃えが維持されます。 この例では、コントロールを作成している Form 必要があります。
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 );
}
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);
}
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
イベントは Layout 、子コントロールが追加または削除されたとき、コントロールの境界が変更されたとき、およびコントロールのレイアウトに影響を与える可能性がある他の変更が発生したときに発生します。 レイアウト イベントは、 メソッドと ResumeLayout メソッドをSuspendLayout使用して抑制できます。 レイアウトを中断すると、変更ごとにレイアウトを実行しなくても、コントロールに対して複数のアクションを実行できます。 たとえば、コントロールのサイズを変更して移動すると、各操作でイベントが Layout 発生します。
イベントの処理の詳細については、「処理とイベントの発生」を参照してください。
製品 | バージョン |
---|---|
.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, 10 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。