Recently, a community member posted a question to the WindowsForms.NET site forums asking about the basic events that are fired in Forms and User Controls in Windows Forms applications. After digging through the MSDN documentation and various other sources (amazingly, it doesn't seem like the complete list is documented in any one place), I came up with the following:
Form Events:
-
Construtor
-
Load
-
Layout
-
Activated
-
Paint
-
Closing
-
Closed
-
Deactivate
-
Dispose
and for Controls:
-
Enter
-
GotFocus
-
Leave
-
Validating
-
Validated
-
LostFocus
I also discovered a code sample called EventSpy written by Urs Eichmann that you can use to view and filter the events to see in real time to see how your application is behaving. This is really helpful to use as you can see which events are fired and in what order as your application runs. Very cool!
[tags:windows forms,lifecycle events]
Thank you very much and was precisely looking for this info! Thanks again!! Anyways i wonder it comes under title Application model and i was searching google whole way to find none!! Don’t ask hw i came here!! Even i dunno!!
Have a good day!
This is really a time saver.
is there any equivalent events on Control class for Closing and Closed?
what is the best event to hook just before a Control is being disposed?
Thank you Paul,
A great job really. You gift me a lot of free time.
It is nice to know the control life cycle when developing custom controls..
Thanks for the post,
Arun Jose
This was one of the most useful articles I have ever read. Thanks for your effort in compiling these events. You have saved me a tremendous amount of time.
it’s really good. thanks a lot for giving this valuable data.