Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between closed and formclosed event

Just wondering whats the big difference between Form.Closed and Form.FormClosed event in the order of events of Windows Application. I've read it in MSDN documentation but still couldn't find anything much different from one another. Please explain.

like image 677
Manikandan Sigamani Avatar asked Sep 07 '12 15:09

Manikandan Sigamani


People also ask

What is the difference between formclosing events and formclosed events?

If the form is a multiple-document interface (MDI) parent form, the FormClosing events of all MDI child forms are raised before the MDI parent form's FormClosing event is raised. Likewise, the FormClosed events of all MDI child forms are raised before the FormClosed event of the MDI parent form is raised.

What happens when a form is closed in Salesforce?

Then ensure that the event handler is associated with the FormClosing event. The FormClosing event occurs as the form is being closed. When a form is closed, it is disposed, releasing all resources associated with the form. If you cancel this event, the form remains opened.

How do I cancel a formclosing event?

The FormClosing event occurs as the form is being closed. When a form is closed, it is disposed, releasing all resources associated with the form. If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the FormClosingEventArgs passed to your event handler to true.

How do I stop a form from closing after closing?

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


1 Answers

As MSDN says:

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

I don't think you should even consider using this event. It's deprecated and hidden but it's there only for compatibility with old source code.

It has the same meaning of the FormClosed event but with one (not so much) subtle difference, as you can see on MSDN the Closed event isn't raised when application exists because of a call to Application.Exit() but the FormClosed is.

This behavior is also documented in the link above:

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.

like image 200
Adriano Repetti Avatar answered Sep 22 '22 01:09

Adriano Repetti