Form.FormClosed 이벤트

정의

폼이 닫힌 후 발생합니다.

public:
 event System::Windows::Forms::FormClosedEventHandler ^ FormClosed;
public event System.Windows.Forms.FormClosedEventHandler FormClosed;
public event System.Windows.Forms.FormClosedEventHandler? FormClosed;
member this.FormClosed : System.Windows.Forms.FormClosedEventHandler 
Public Custom Event FormClosed As FormClosedEventHandler 

이벤트 유형

예제

다음 예제에서는 이 멤버의 사용을 보여 줍니다. 예제에서는 이벤트 처리기에서 보고서를 FormClosed 이벤트입니다. 이 보고서를 통해 이벤트 발생 하 고 도움이 될 수 있습니다 디버깅 하는 경우를 학습할 수 있습니다. 자주 발생 하는 이벤트 또는 여러 이벤트를 보고 하려면 바꾸는 것이 좋습니다 MessageBox.Show 사용 하 여 Console.WriteLine 줄에 메시지를 추가 또는 TextBox합니다.

예제 코드를 실행 하려면 형식의 인스턴스를 포함 하는 프로젝트에 붙여넣습니다 Form 라는 Form1합니다. 연결 된 이벤트 처리기는 확인 된 FormClosed 이벤트입니다.

private void Form1_FormClosed(Object sender, FormClosedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "FormClosed Event" );
}
Private Sub Form1_FormClosed(sender as Object, e as FormClosedEventArgs) _ 
     Handles Form1.FormClosed

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"FormClosed Event")

End Sub

설명

이벤트는 FormClosed 폼이 사용자 또는 메서드 또는 Exit 클래스의 Close 메서드에 의해 닫힌 후에 발생합니다Application. 폼이 닫히지 않도록 하려면 이벤트를 처리 FormClosing 하고 이벤트 처리기에 true전달된 의 CancelEventArgs 속성을 로 설정합니다Cancel.

이 이벤트를 사용하여 양식에서 사용하는 리소스를 해제하는 등의 작업을 수행하고 양식에 입력한 정보를 저장하거나 부모 양식을 업데이트할 수 있습니다.

양식이 MDI(다중 문서 인터페이스) 부모 양식인 경우 MDI 부모 폼 FormClosing 의 이벤트가 발생하기 전에 모든 MDI 자식 폼의 FormClosing 이벤트가 발생합니다. 마찬가지로 MDI FormClosed 부모 폼의 이벤트가 발생하기 전에 FormClosed 모든 MDI 자식 폼의 이벤트가 발생합니다.

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

적용 대상

추가 정보