473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Changes View in a Windows Form

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

Nov 17 '05 #1
5 1395
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

Nov 17 '05 #2
Cool,

Thanks for the info Charlie. My idea is basically, the user starts up
the application and the first view is a log-in view to enter their
username and password. This would be my first user control this log-in
view.

Then if successful it goes to the second view which would be my second
user control.

I would just need to alternate between the first usercontrol and second
usercontrol. Thanks

Danny

Nov 17 '05 #3
On 26 Aug 2005 15:37:14 -0700, fe***********@gmail.com wrote:
Cool,

Thanks for the info Charlie. My idea is basically, the user starts up
the application and the first view is a log-in view to enter their
username and password. This would be my first user control this log-in
view.

Then if successful it goes to the second view which would be my second
user control.

I would just need to alternate between the first usercontrol and second
usercontrol. Thanks

Danny


Your idea with multiple panels is not bad either. That's what they are
for, anyway.

On the other hand, you may also want to ditch the idea of a single
form and just create multiple forms. Otherwise you just facing much
more work while trying to make a single form perform like a wizard.
Nov 17 '05 #4
I'm still new to these windows forms thing. Do you of any URL links
that show an example of a multiple form app. Thanks

Danny

Nov 17 '05 #5
On 26 Aug 2005 17:27:54 -0700, fe***********@gmail.com wrote:
I'm still new to these windows forms thing. Do you of any URL links
that show an example of a multiple form app. Thanks

Danny


Danny,

I suggest you read the documentation and look into the sample code
provided with Visual Studio .NET 2003; forms are quite straighforward.
Yet this is just too much to explain in a single post here.

But, in general, you can easily instantiate and display any custom
form from any other form like this.

// Create form instance
MyOtherForm form = new MyOtherForm();

// Display form
form.Show();

- or -

// Display form modally
form.ShowDialog();

- or -

// Display form as modal to the current form
form.ShowDialog( this );
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeremy Smith | last post by:
I have a Access 2K2 db that is used on the network. I have a main form that dependant upon the selected option loads the appropriate subform. when it does this several label captions change to...
9
by: AP | last post by:
I personally cannot stand the Allow Design Changes property set to anything other than design view. Is there a way to loop through all forms and set this property to design view only? There always...
6
by: Lance Geeck | last post by:
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip. I have the fields bound to the dataset field. (Properties...
6
by: nickybon | last post by:
Hi fellas, Im setting up a form in my Access project and I need to implement this rather special fucntion. This function is basically simple to understand but I really dont know how to create...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
3
by: idletask | last post by:
I have an application that has many windows. One window is used for order processing. I would like this window to display the other users who are also performing order processing (the idea is to...
0
by: Patty05 | last post by:
I have a datagrid on a form that update properly when form loads. When the program runs and I type in/add a new row in the datagrid, it does not save the changes. Any help would be greatly...
3
by: mfetterhoff | last post by:
Hello Experts.. Im checking out the other side of the tracks here.. always been a Systems Analyst kind of guy. Developers are a touchy and unpredictible lot. I try to give them their space and never...
2
by: ncsthbell | last post by:
I made some minor code changes to a form (not the main form), closed the app and when I try to open it, my main form will not open, I have a blank screen. I also tried going back into the form I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.