I have a form which I want to show modally; it's a fairly old form
that's been ported up several versions of VB, and I'd like to keep its
rewriting to a minimum. Basically, it is used in this sequence:
1. The form is shown. The Form_Load event does some initialization.
2. Further parameters are passed to this form.
3. We actually need this form to be modal, so we hide it and show it
again modally.
4. Stuff happens on the form based on the parameters passed in, etc.
(The VB.NET code for this is below.) However, I've discovered that
calling ShowDialog() in step #3 fires off the Form_Load event a second
time, even though it's the same object instance. Does any instance of
showing a form fire this event?
(My problem here is that the Form_Load initialization should only
happen once. I could use an already_initial ized flag, but that's
horribly messy; if I have to, I'd rather pass Foo in the constructor
and hold onto it through the Form_Load process.)
--Caitlin Shaw
**Code**
Private WithEvents frmThing As ThingForm
Public Sub DoThatThingWith Foo(Foo as Object)
'Create the thing and set it up
frmThing = New ThingForm()
frmThing.Show()
frmThing.DoSome Setup(Foo)
'Really, though, we want this thing to be modal
frmThing.Hide()
frmThing.ShowDi alog()
'Good, that's done
frmThing.Dispos e()
End Sub