By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

Form Load Event Behavior...

P: n/a
I am experiencing some unexpected behavior with the Form Load event in a
Windows application. Hopefully, someone can explain why this behavior is

In my application, I have a form that I would like to show multiple times
throughout the life of the application. The startup code for this form can
be quite lengthy so I am hiding and showning the form (versus unloading and
loading it). If I show the form non-modally (using the Show method), the
code in the Load event is fired only one time. If I show the form modally
(using the ShowDialog method), the code in the Load event is fired every time
I make the form visible.

Is there an explanation as to why this behavior is occuring?

Thank you,

Jason Richmeier
Apr 25 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi Jason,

Thank you for posting.

As you know, it's different for a winform to display modal or modeless.

Firstly, if a winform is loaded for the first time, whether in the modal
mode or modeless mode, the load event of the winform will be raised.

Secondly, after the winform is shown modeless, the program control will
return to the place where the sentence called to open the form is and the
code following this sentence will be executed. On the contrary, if the
winform is shown modal, the code following the sentence will not executed
until the winform is closed.

Thirdly, if you hide a modeless winform , the winform will be invisible but
not be unloaded. While if you hide a modal winform , the winform will be
invisible and unloaded but not disposed. The code following the sentence
that showes the winform in the modal mode will be executed now. Then if
you show a modeless winform again, the winform will be visible again but
the load event will not be raised. While if you show a modal winform
again, the winform will be loaded again and the load event will be raised.

Hope I am making sense.

If you have any other concerns or need anything else, please don't hesitate
to tell me.

Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Apr 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.