다음을 통해 공유


Form.OnClosed 메서드

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Protected Overridable Sub OnClosed ( _
    e As EventArgs _
)
‘사용 방법
Dim e As EventArgs

Me.OnClosed(e)
protected virtual void OnClosed (
    EventArgs e
)
protected:
virtual void OnClosed (
    EventArgs^ e
)
protected void OnClosed (
    EventArgs e
)
protected function OnClosed (
    e : EventArgs
)

매개 변수

  • e
    이벤트 데이터가 들어 있는 EventArgs입니다.

설명

이벤트를 발생시키면 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 발생시키기를 참조하십시오.

또한 OnClosed 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.

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

예제

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

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
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 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 extends Form
{
    protected void OnClosed(EventArgs e)
    {
        MessageBox.Show("The form is now closing.", "Close Warning", 
            MessageBoxButtons.OK, MessageBoxIcon.Warning);
        super.OnClosed(e);
    } //OnClosed

    public myForm()
    {
        super();
    } //myForm
} //myForm

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Form 클래스
Form 멤버
System.Windows.Forms 네임스페이스
Closed
EventArgs