Home All Groups Group Topic Archive Search About
Author
26 Mar 2005 12:49 AM
Dennis
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

Author
26 Mar 2005 1:41 AM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Dennis" <Den***@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/>
Author
26 Mar 2005 2:23 AM
Dennis
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!

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "Dennis" <Den***@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/>
>
>
Author
26 Mar 2005 2:47 AM
Herfried K. Wagner [MVP]
"Dennis" <Den***@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/>