471,319 Members | 3,066 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Multiple screens on the same form

Hi. Is there someone that can tell me how can I have multiple screens
on the the same form, displaying only on at the time?

Thank you all for any replys.

Joćo Carias

Jan 10 '06 #1
9 4396
Hello Quina,
Multiple Screens? Tell us, more about this..
Regardings...
Bahadir ARSLAN
www.maxiasp.net
Hi. Is there someone that can tell me how can I have multiple screens
on the the same form, displaying only on at the time?

Thank you all for any replys.

Joćo Carias

Jan 10 '06 #2
Have you thought of using tab pages.
"Quina" <ca*********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi. Is there someone that can tell me how can I have multiple screens
on the the same form, displaying only on at the time?

Thank you all for any replys.

Joćo Carias
Jan 10 '06 #3
Quina wrote:
Hi. Is there someone that can tell me how can I have multiple screens
on the the same form, displaying only on at the time?

Thank you all for any replys.

Joćo Carias


I had a requirement to have countless forms to be displayed. Instead of
using a TabControl (which I would have for a lesser number of forms) I
used a treeview control on the left hand side of a main form to navigate
the collection of forms, then loaded the required form in the right hand
section of the main form based on the TreeNode selected. I set the main
form IsMdiContainer to true and set the childs forms MdiParent to the
Main Form. Maybe not the best way but it seems to work.

Thanks,
Ross McLean
Jan 10 '06 #4
This depends upon the effect you want.

Do you want all of the screens to be accessible to the user on demand,
in any order? Then, as Mark Carew pointed out, you should use a
TabControl.

Or, perhaps you want a "wizard" style interface, where the program
guides the user through the pages in a certain order, offering "Next"
and "Back" buttons. In this case, I would recommend making each "page"
a UserControl (a separate .cs file) and then placing all of the
resulting UserControls together on the final Form. Then you can handle
Next like this:

this._panel2.Hide();
this._panel3.Dock = DockStyle.Fill;
this._panel3.Show();

In order to handle the Back functionality, I recommend creating a Stack
on which you push UserControls as you Show() them, then if the user
presses a Back button then just pop the topmost UserControl from the
stack and Hide() it, and Show() the UserControl that is now topmost on
the stack.

Anyway, that's how I implemented a "wizard" style user interface.

Jan 10 '06 #5
Ok here is the deal: I whant to use a single form with many diferent
interfaces according to a menu, perhaps on the left of the form, for
example like MS Outlook .
My first thouth was using a TabControl (as Mark Carew refered) but, it
is impossible to hide the tabs.
Then I tryed to use an mdiForm (Ross McLean's sugestion)... well, it
works, but I cannot press Ctrl+F6 or the forms will chance.
The Panels solution doeslook good, but it is way too out my leage!! I'm
C# and VStudio beginner... Never the less, I would apreciate some more
info on this, specially on the separete .cs files.

Thank you all for your replys,
sincerely,

Joćo Carias

Jan 11 '06 #6
The panels thing shouldn't be too hard.

Just use Visual Studio to create a new UserControl and give it a name
indicating what one of the panels (screens) is for.

Make the UserControl as big as you need it to be, and lay out controls
the UserControl so that it looks the way you want (say) the first panel
to look. The UserControl that you created will appear as a separate .cs
(and corresponding .resx) file in your project.

Then, create a new Form class for your main application. Go the toolbox
at the left of Visual Studio and click on (I think it's) the "User
Components" section of the toolbox. You should see your UserControl
named there. Just drag it onto the design surface like you would any
other control.

Now you can use .Show() and .Hide() in your code to make the correct
panels appear / disappear when the user indicates a choice.

The only tricky part is if you want a "Back" button to go back to the
previous panel that the user was looking at, but don't worry about that
for now.

Yes, you can do this without UserControls, just by putting lots of
Panels on your design surface and laying each Panel out, but trust me:
this will quickly become a nightmare. It's a lot easier to make each
separate panel (or screen) a separate UserControl, and then manipulate
the UserControls as wholes, rather than fiddling about with individual
panels and their contents all the time.

Jan 11 '06 #7
One more option which has not been mentioned is to "re-parent" a form to
appear in a panel in another form... I'm doing this in one of my apps and
it is by far the "cleanest" way I found.. I am quite happy with it because
there are no unusual things to do (ie, create controls, etc...) except for
the reparenting.

Basically you design each form as if it were a normal form in the VS form
designer. Then at runtime, you re-parent the form to reside inside another
form's panel or similar container. All of the events work as if it were a
standalone form, and all your code is nicely separated in the various .cs
files. When you need to display a different "page" then you close and
de-allocate the currently displayed form and create, reparent, and display
the new form. This is done with a suprisingly little amount of code.

I do not have access to my code for that from here, but here is a link to
point you to the right direction in how this is done:
http://dotnet247.com/247reference/msgs/5/28648.aspx
"Quina" <ca*********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi. Is there someone that can tell me how can I have multiple screens
on the the same form, displaying only on at the time?

Thank you all for any replys.

Joćo Carias
Jan 11 '06 #8
Thanks Bruce, it works just fine!
I would like also to thank you all for your kind sugestions.

Joćo Carias

Jan 12 '06 #9
I am trying to do something along these lines. Whether you use user controls
or not, the problem is being able to work with the controls in the design
view, because they are all on top of each other. Is there any way to make a
control or a set of controls (a panel and its child controls) invisible *in
the design view*?
--
Dave
"Bruce Wood" wrote:
The panels thing shouldn't be too hard.

Just use Visual Studio to create a new UserControl and give it a name
indicating what one of the panels (screens) is for.

Make the UserControl as big as you need it to be, and lay out controls
the UserControl so that it looks the way you want (say) the first panel
to look. The UserControl that you created will appear as a separate .cs
(and corresponding .resx) file in your project.

Then, create a new Form class for your main application. Go the toolbox
at the left of Visual Studio and click on (I think it's) the "User
Components" section of the toolbox. You should see your UserControl
named there. Just drag it onto the design surface like you would any
other control.

Now you can use .Show() and .Hide() in your code to make the correct
panels appear / disappear when the user indicates a choice.

The only tricky part is if you want a "Back" button to go back to the
previous panel that the user was looking at, but don't worry about that
for now.

Yes, you can do this without UserControls, just by putting lots of
Panels on your design surface and laying each Panel out, but trust me:
this will quickly become a nightmare. It's a lot easier to make each
separate panel (or screen) a separate UserControl, and then manipulate
the UserControls as wholes, rather than fiddling about with individual
panels and their contents all the time.

Feb 26 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Lizim | last post: by
3 posts views Thread by Martin | last post: by
reply views Thread by question | last post: by
3 posts views Thread by Steve Marshall | last post: by

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.