Click here to Skip to main content
15,891,847 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all,

I need to use one method to access all the forms
Load events in my project.
How is this possible without opening every form
and then opening its load event.

There is to much forms to do this one by one.

Please any help would be appriciated>
Posted
Comments
Oshtri Deka 5-Mar-12 4:08am    
Don't be lazy :)
Dave Kreskowiak 5-Mar-12 11:32am    
Wow. If you have to trip every Load event in every form in your app, you've got a SERIOUS design flaw in every one of your forms.

1 solution

Any solution we gave would require you to change every form class anyway, so get used to it!

The simplest way to do it is to declare your own MyForm class (derived from Form), which handles the Load event and derive all your forms from that instead of Form
This would catch all the uses of
C#
formThis thisForm = new formThis();
without having to manually add the event handler as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900