Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Form Load Events

0 views
Skip to first unread message

Charles A. Lackman

unread,
Jan 4, 2010, 6:36:49 PM1/4/10
to
Hello All,

I have a large application with multiple Windows Forms. I have code that
needs to be executed in the Load Event of every Form in the application and
was wondering if there was a way to add the code without having to go to
each form and copy and paste?

Is there a global location to override all the Load Events?

Thanks,

Chuck


Armin Zingler

unread,
Jan 4, 2010, 6:53:42 PM1/4/10
to
Charles A. Lackman schrieb:

If it's possible to derive all Forms from your own base Form, you
can put the common code into the (overridable) OnLoad method of
the base Form.

--
Armin

Scott M.

unread,
Jan 4, 2010, 6:58:30 PM1/4/10
to
If each form needs the exact same code, you are going to have some
repetition, but instead of putting the full-blown code in each Form_Load,
why not create the code in a separate class that gets instantiated when your
first form is created and then each Form_Load can simply have a single line
method call into that instance?

This way you'll reduce the amount of code repitition and if you ever need to
change the Form_Load code, you'll only have to do it in one place.

-Scott

"Charles A. Lackman" <Cha...@CreateItSoftware.net> wrote in message
news:%23tDZDbZ...@TK2MSFTNGP02.phx.gbl...

0 new messages