When developing Windows applications using Windows Forms, you will most likely find yourself needing to make use of the form’s events, and this requires you to know when each form event fires. In this short reference article I will show you the sequence of the form events when the Form is being started and when it is being shut down.
Form Start up
Event | Description | |
1. | Control.HandleCreated | Occurs when a handle is created for the control. |
2. | Control.BindingContextChanged | Occurs when the value of the BindingContext property changes. |
3. | Form.Load | Occurs before a form is displayed for the first time. |
4. | Control.VisibleChanged | Occurs when the Visible property value changes. |
5. | Form.Activated | Occurs when the form is activated in code or by the user. |
6. | Form.Shown | Occurs whenever the form is first displayed. |
Form Shutdown
Event | Description | |
1. | Form.Closing | Occurs when the form is closing. |
2. | Form.FormClosing | Occurs before the form is closed. |
3. | Form.Closed | Occurs when the form is closed. |
4. | Form.FormClosed | Occurs after the form is closed. |
5. | Form.Deactivate | Occurs when the form loses focus and is no longer the active form. |
Note that the Form.Closing
and the Form.Closed
events are obsolete in the .NET Framework version 2.0. You must use Form.FormClosing
and Form.FormClosed
instead.
Dave