Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between FormClosed and FormClosing event

Tags:

forms

vb.net

In VB.NET what is the difference between FormClosed and FormClosing event?

Private Sub frmTerminal_TCP_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing

End Sub


Private Sub frmTerminal_TCP_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

End Sub
like image 531
Cary Bondoc Avatar asked Oct 08 '15 00:10

Cary Bondoc


1 Answers

FormClosing happens before FormClosed. Think of FormClosing like the dialog that ask you to save your document before quitting the program. It gives you an opportunity to cancel the window's termination.

FormClosed is triggered after the form has closed. From MS documentation:

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.

like image 107
Code Different Avatar answered Oct 11 '22 05:10

Code Different