Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello,

All we know that developing a GUI is very important, i was developing a configuration module for a project into that there were many settings like user setting, software setting, font setting.

For each setting i had taken separate forms. I had a following menu:

Setting
- User Setting
- Software Setting
- Font Setting

On each click of sub-menu item i am redirecting to respective form.

Instead can we do in single form where user will select appropriate option and accordingly besides screen will be changed. Like we have tabs on every tab click screen changes on single form.

Like when we go to Project properties of project in visual studio.

Can any one suggest a way to do it single Form?

Thanks and Regards,
Joseph.
Posted
Updated 5-Oct-10 19:52pm
v2

Use something like Panels. Stack them, as pointed before by a fellow programmer. But don't design them all in a class.
Create a base class:
public class MyTab : UserControl

Then, make and design your individual tabs in individual files:
public sealed class MyFirstTab : MyTab

public sealed class MySecondTab : MyTab

And so on...
Finally, in your Form:
private List<MyTab> myTabs = new List<MyTab>();

Add the tabs to the List:
myTabs.Add(new MyFirstTab());
myTabs.Add(new MySecondTab());
//...

And add them to the Form:
this.Controls.AddRange(myTabs.ToArray());

So, when you need one of them, you just have to remember its ordinal number. (If you want to refine it, you may store them in a Dictionary<string, MyTab> and refer them by name instead)
myTabs[index].BringToFront();

Hope that helps.
An Accept Answer helps me too ;-)
 
Share this answer
 
You can keep separate forms and code behind for each settings.
Create a main form and add each form on menu click.
It will be good if you use Microsoft UIP Application block for windows form projects.

Regards
Sajith OD
 
Share this answer
 
You should use the panel control ,so that you will be able to dispaly or hide a particular form when u need it.
 
Share this answer
 
Do one thing make a panel and make user control forms instead Forms. Make the panel as visible when particular Menu item selected so that they will be shown in the same form. Make particular user control visible based on your selection.

A small code

//Under Menu selected Item

<code></code>     pnlACH.Controls.Clear();//Panel
                       pnlACH.Visible = true;
                       UserControl usrcntrlfileheader = new UsrCntrlFileHeader();//User Control
                      usrcntrlfileheader.Show();
                      pnlACH.Controls.Add(usrcntrlfileheader);


Like this load the corresponding user control.
 
Share this answer
 
v2
Why not use a tab control? This is what I've seen most commonly. Or you could stack panels and your submenu control could bring the correct panel to the top of the z-order.
 
Share this answer
 
Comments
prashant joseph 6-Oct-10 4:31am    
Actually i have more number of such screens... So it would not look good. That's why i am not preferring. In second case there would me complexity for designing such number of panel in single .cs file.
Gordon Kushner 6-Oct-10 4:46am    
You could make the application an MDI (multiple document) so that the container form has the menu and you actually load and unload child forms. If you make the child forms maximized, they appear to be part of the main form. Just a thought.
Toli Cuturicu 6-Oct-10 15:17pm    
Better not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900