Form.OnClosed(EventArgs) 메서드

정의

Closed 이벤트를 발생시킵니다.

protected:
 virtual void OnClosed(EventArgs ^ e);
protected virtual void OnClosed (EventArgs e);
abstract member OnClosed : EventArgs -> unit
override this.OnClosed : EventArgs -> unit
Protected Overridable Sub OnClosed (e As EventArgs)

매개 변수

e
EventArgs

이벤트 데이터를 포함하는 EventArgs입니다.

예제

다음 예제에서는 에서 파생 된 Form 클래스에서 메서드를 재정의 OnClosed 하는 방법을 보여 줍니다.

public ref class myForm: public Form
{
protected:
   virtual void OnClosed( EventArgs^ e ) override
   {
      MessageBox::Show( "The form is now closing.", "Close Warning", MessageBoxButtons::OK, MessageBoxIcon::Warning );
      Form::OnClosed( e );
   }

public:
   myForm()
      : Form()
   {}

};
public class myForm:
    Form

{
    protected override void OnClosed(EventArgs e)
    {
        MessageBox.Show("The form is now closing.", 
            "Close Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        base.OnClosed(e);
    }

    public myForm() : base()
    {        
    }
}
Public Class myForm
    Inherits Form

    Protected Overrides Sub OnClosed(ByVal e As EventArgs)
        MessageBox.Show("The form is now closing.", "Close Warning", _
            MessageBoxButtons.OK, MessageBoxIcon.Warning)
        MyBase.OnClosed(e)
    End Sub

    Public Sub New()
        MyBase.New()
    End Sub

End Class

설명

주의

메서드는 OnClosed .NET Framework 2.0부터 사용되지 않습니다. 대신 메서드를 OnFormClosed 사용합니다.

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생합니다.

또한 OnFormClosed 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 이 메서드를 재정의하는 것은 파생 클래스에서 이벤트를 처리하는 데 선호되는 기술입니다.

주의

OnClosed 하 고 OnClosing 메서드 호출 되지 않습니다는 Application.Exit 메서드를 호출 하 여 애플리케이션을 종료 합니다. 실행해야 하는 이러한 메서드 중 하나에 유효성 검사 코드가 있는 경우 메서드를 호출하기 전에 열려 있는 각 양식에 대해 메서드를 Exit 개별적으로 호출 Form.Close 해야 합니다.

상속자 참고

파생 클래스에서 OnClosed(EventArgs)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnClosed(EventArgs) 메서드를 호출해야 합니다.

적용 대상

추가 정보