다음을 통해 공유


Control.Resize 이벤트

정의

컨트롤의 크기를 조정할 때 발생합니다.

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

이벤트 유형

예제

다음 코드 예제에서는 .의 Resize 이벤트를 처리합니다 Form. 폼의 크기가 조정되면 이벤트 처리기는 폼이 정사각형으로 Height 유지되고 Width 동일하게 유지되도록 합니다. 이 예제를 실행하려면 이 이벤트 처리 메서드를 폼의 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 메서드의 매개 변수를 a Control 로 캐스팅 sender 하고 해당 Size 속성(또는 HeightWidth 속성을 개별적으로)으로 가져올 수 있습니다.

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

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

적용 대상

추가 정보