Danny,
If your views are preset ahead of time, panels would work fine but I prefer creating User Controls (UC). They are just as easy to create and don't clutter up your work space. If you want, you can drop them on your form or any other form (then acts similar or better than a panel.) A UC is almost the same as creating a new form with the main difference being that the UC can't execute by itself, must be used within another container (like a winform).
You can easily activate the UC at runtime.
if (userSelected == option1)
myUC1 View1 = new myUC1(); //assumes visible is set to true.
else
if (userSelected == option2)
myUC2 View2 = new myUC2();
If it makes sense, you could declare an interface and eliminate the need to have multiple View1, View2 variables and replace with just one variable like theView.
or you could try casting your custom user control down to UserControl:
UserControl theView = new (UserControl)myUC1();
UserControl theView = new (UserControl)myUC2();
Probably will still do you want because the objects on myUC1 or 2 are contained within the ControlCollectioin of the UC and will still be available in the base UC rather than only via myUC1 or myUC2
Hope this all makes sense.
Charlie
:-)
<fe***********@gmail.com> wrote in message news:11*********************@g43g2000cwa.googlegro ups.com...
Hi
My question is how to change the view of my windows form. What I want
to do is in my Windows Form is first ask the user some questions, when
the user is done she pushes a button called next.
Based on the input from the user, I would display the appropriate view
on the form.
I just don't how to do this. Should I create two panels(panel1 and
panel2) and keep one visible(panel1). Then when the user clicks next I
make panel2 visible an d panel1 invisble.
I appreciate any advice or where to get more info.
Danny