Edit

Share via


Form.Closed Event

Definition

Caution

Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.

Occurs when the form is closed.

public:
 event EventHandler ^ Closed;
public event EventHandler Closed;
[System.ComponentModel.Browsable(false)]
public event EventHandler Closed;
[System.ComponentModel.Browsable(false)]
[System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public event EventHandler? Closed;
[System.ComponentModel.Browsable(false)]
public event EventHandler? Closed;
member this.Closed : EventHandler 
[<System.ComponentModel.Browsable(false)>]
member this.Closed : EventHandler 
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("Form.OnClosing, Form.OnClosed and the corresponding events are obsolete. Use Form.OnFormClosing, Form.OnFormClosed, Form.FormClosing and Form.FormClosed instead.", false, DiagnosticId="WFDEV004", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
member this.Closed : EventHandler 
Public Custom Event Closed As EventHandler 

Event Type

Attributes

Remarks

Caution

The Closed event is obsolete in .NET Framework version 2.0; use the FormClosed event instead.

This event occurs after the form has been closed by the user or by the Close method of the form. To prevent a form from closing, handle the Closing event and set the Cancel property of the CancelEventArgs passed to your event handler to true.

You can use this event to perform tasks such as freeing resources used by the form and to save information entered in the form or to update its parent form.

Caution

The Form.Closed and Form.Closing events are not raised when the Application.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form.Close method for each open form individually before calling the Exit method.

If the form is an MDI parent form, the Closing events of all MDI child forms are raised before the MDI parent form's Closing event is raised. In addition, the Closed events of all MDI child forms are raised before the Closed event of the MDI parent form is raised.

For more information about handling events, see Handling and Raising Events.

Applies to

See also