Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# GUI
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 5-Oct-10 20:51pm
Edited 5-Oct-10 20:52pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
prashant joseph at 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.
gkushner at 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 at 6-Oct-10 15:17pm
   
Better not.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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>     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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

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 Wink | ;-)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You should use the panel control ,so that you will be able to dispaly or hide a particular form when u need it.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 6 Oct 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100