How to Switch Between Forms?

melegant

Regular
Joined
Feb 2, 2003
Messages
52
Location
NY
Lets say I have two forms that I wish to switch back and forth from, until the user is ready to go on to a 3rd Form

(My program acts sort of like a wizard)

So,
In Form1 I have button which

Visual Basic:
Dim frm2 as New Form2()
Form2.Show
Me.Hide

now that I am on Form 2, how to I get back to Form1 from Form2, with all the text boxes still holding the values before I called the Me.Hide method?

Thanks!

p.s. a thought occured to me, could I pass the form to the next forms constructer? Should I create a Class that houses all my forms as properties? (is that possible?)
 
Last edited:
Passing the instance to the new form's constructor using the Me (or this) keyword is usually me preferred way of keeping the instances around.
 
I'd chose the way of creating a "WizardManager" class.

All of your forms 1 .. n would implement an interface IWizardMember, i.e. a show and a hide method, some events (movenextpressed, movebackpressed, cancelpressed, finishpressed).

The WizardManager could keep a list of the forms 1..n, react to the events thrown and make calls to the forms' IWizardMember Interface.
 
Back
Top