Control.Resize 이벤트

정의

컨트롤의 크기를 조정하면 발생합니다.

public:
 event EventHandler ^ Resize;
public event EventHandler Resize;
public event EventHandler? Resize;
member this.Resize : EventHandler 
Public Custom Event Resize As EventHandler 

이벤트 유형

예제

다음 코드 예제에서는 의 이벤트를 처리 합니다 ResizeForm. 폼 크기가 조정되면 이벤트 처리기는 폼이 정사각형으로 HeightWidth 유지되고 동일하게 유지되도록 합니다. 이 예제를 실행하려면 이 이벤트 처리 메서드를 양식의 Resize 이벤트와 연결해야 합니다.

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.Size.Height != control.Size.Width)
   {
      control.Size = new Size(control.Size.Width, control.Size.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

설명

크기가 조정된 컨트롤의 를 확인 Size 하려면 등록된 ControlEventHandler 메서드의 매개 변수를 로 Control 캐스팅 sender 하고 해당 Size 속성(또는 HeightWidth 속성을 개별적으로)을 가져올 수 있습니다.

사용자 지정 레이아웃을 처리하려면 Resize 이벤트 대신 이벤트를 사용합니다 Layout . Layout 대 한 응답으로 이벤트 발생을 Resize 컨트롤의 레이아웃에 영향을 주는 다른 변경에 대 한 응답 뿐만 아니라 이벤트입니다.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보