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

Form Load Event

P: n/a
I have the following code for showing a form:

dim frm as new myForm

frm.ShowDialog (The Form Load Event is fired then I hide the form using
Me.Hide when the X in the UR corner is clicked).

'Do something in code

frm.ShowDialog (The Form Load Event fires again)

Shouldn't the Form Load event fire only once when the form is first shown
and not again unless I do a form.close first?
......
--
Dennis in Houston
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
I have the following code for showing a form:

dim frm as new myForm

frm.ShowDialog (The Form Load Event is fired then I hide the form using
Me.Hide when the X in the UR corner is clicked).

'Do something in code

frm.ShowDialog (The Form Load Event fires again)

Shouldn't the Form Load event fire only once when the form is first shown
and not again unless I do a form.close first?


'Load' will be raised prior to showing the form, so it can be raised more
than once. If code should only be executed on time for each form instance,
add the code in the form's constructor directly after the call to
'InitializeComponent'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
If the load event is going to be fired each time I show the form, then what's
the difference between the Load Event and the Activated EVent...they both
seem to fire whenever I show the form? Thanks for help Herfried!

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
I have the following code for showing a form:

dim frm as new myForm

frm.ShowDialog (The Form Load Event is fired then I hide the form using
Me.Hide when the X in the UR corner is clicked).

'Do something in code

frm.ShowDialog (The Form Load Event fires again)

Shouldn't the Form Load event fire only once when the form is first shown
and not again unless I do a form.close first?


'Load' will be raised prior to showing the form, so it can be raised more
than once. If code should only be executed on time for each form instance,
add the code in the form's constructor directly after the call to
'InitializeComponent'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
If the load event is going to be fired each time I show the form, then
what's
the difference between the Load Event and the Activated EVent...they both
seem to fire whenever I show the form? Thanks for help Herfried!


The 'Activated' event will fire too then the form looses focus and is
reactivated later.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.