Control.Resize イベント
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Event Resize As EventHandler
public event EventHandler Resize
public: event EventHandler^ Resize { void add (EventHandler^ value); void remove (EventHandler^ value); }
/** @event */ public void add_Resize (EventHandler value) /** @event */ public void remove_Resize (EventHandler value)

サイズ変更されたコントロールの Size を決定するには、EventArgs データの sender パラメータを Control にキャストしてその Size プロパティを取得するか、Height プロパティまたは Width プロパティを個別に取得します。
カスタム レイアウトを処理するには、Resize イベントではなく Layout イベントを使用します。Layout イベントは、Resize イベントへの応答として発生しますが、コントロールのレイアウトに影響する他の変更への応答としても発生します。

Form の Resize イベントを処理するコード例を次に示します。フォームのサイズが変更されるとき、そのフォームはイベント ハンドラによって正方形に保たれます。つまり Height と Width が等しい値のままになります。
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize Dim myControl As Control myControl = sender ' Ensure the Form remains square (Height = Width). If myControl.Size.Height <> myControl.Size.Width Then myControl.Size = New Size(myControl.Size.Width, myControl.Size.Width) End If End Sub
private void Form1_Resize(object sender, System.EventArgs e) { Control control = (Control)sender; // Ensure the Form remains square (Height = Width). if(control.Size.Height != control.Size.Width) { control.Size = new Size(control.Size.Width, control.Size.Width); } }
private: void Form1_Resize( Object^ sender, System::EventArgs^ /*e*/ ) { Control^ control = dynamic_cast<Control^>(sender); // Ensure the Form remains square (Height = Width). if ( control->Size.Height != control->Size.Width ) { control->Size = System::Drawing::Size( control->Size.Width, control->Size.Width ); } }
private void Form1_Resize(Object sender, System.EventArgs e) { Control control = (Control)sender; // Ensure the Form remains square (Height = Width). if (control.get_Size().get_Height() != control.get_Size(). get_Width()) { control.set_Size(new Size(control.get_Size().get_Width() , control.get_Size().get_Width())); } } //Form1_Resize

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Control.Resize イベントのページへのリンク