Click here to Skip to main content
15,887,453 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hi,

I have on Winform on that I have tabs like
"Inward", "Office", "Dealer",

so I want new tab as "Outward" and "Account" inside Dealer tab

I am making window base application.
Posted

This would be a really bad design idea. Tab page inside tab page can greatly confuse the user. If you have two values of hierarchy or more, either use two distinct different styles of navigation, or use just one specially designed (and well recognized by the users) navigation element: tree view.

This is how it can look: on left, place a tree view. On right: a set of panels (for example) showing one panel at a time; those panel will play the role of tab page. (This left-to-right layout would be for Western cultures, for cultures using right-to-left writing system, right-to-left layout would be more adequate.)

Then associate with all or some nodes an instance of a panel on right (if not for all, some nodes would play the role of just topic headers). Handle the selection events of the tree view to show associated instance of the panel of right and hide other panels. Each panel would have different content. Isn't that simple? This is the design style used by, for example, Microsoft Properties pages, like in Visual Studio and other newer options and properties windows.

—SA
 
Share this answer
 
Comments
BillWoodruff 17-Feb-15 5:14am    
+4 good design ideas; hopefully, between your answer, and mine, the OP will learn something.
> You can't put a tab control on a page of another tab control. I know of
> two workarounds:
>
> 1. Put a subform on the tab page, and put the new tab control on that
> subform.
>
> 2. Put the new tab control on the form in front of the original tab
> control, and use the original tab control's Change event to make the new
> tab control visible only when the original tab is on the desired page.


According to these answers.
http://database.ittoolbox.com/groups/technical-functional/access-l/can-you-put-a-tab-control-within-a-tab-control-on-an-access-form-1755436[^]
http://msgroups.net/microsoft.public.access.forms/can-you-add-a-tab-control-insid/126714[^]
http://bytes.com/topic/access/answers/199835-tab-control-within-another-tab-control[^]
 
Share this answer
 
Comments
Zakaria Jagral 17-Feb-15 1:51am    
Not suitable for my requirement
/\jmot 17-Feb-15 1:54am    
then whats your question???
update your question.
You certainly can put a TabControl in a TabPage of another TabControl, but I agree with Sergey's opinion that this results in a poor user-interface experience. I've seen a UI where the TabControl-inside-a-TabPage displayed its Tabs vertically using TabControl.Alignment set to TabAlignment.Left: difficult to read the Tabs, imho. Also, note that even if you set the a TabPage's Font 'GdiVerticalFont property to 'true, it has no effect (not with any Font I have tried anyway): the font is not displayed in "truly" vertical fashion.

Keep in mind that you can create many TabPages at design-time inside a TabControl and configure their user interfaces as you like, wire-up EventHandlers for their Controls, and, at run-time, create a collection of them, then remove any of them you wish, and restore them from the collection when you need to. That involves some work, is not usually done, and if you are new to WinForms programming I would suggest you not take this on, but, it is possible.

The answer to the question you should be asking now is: yes, if you restore a removed TabPage to a TabControl from a valid collection of TabPages, the Event Handlers you have defined for its internal Controls are still there, and will fire events as expected.

For example, this removes all TabPages except the first one, and stores the removed TabPages in a List:
C#
private List<tabpage> TheTabPages;

private void Form1_Load(object sender, EventArgs e)
{
    TheTabPages = new List<tabpage>();

    // must do this before iterating
    int tabCount = tabControl1.TabPages.Count;

    for (int i = 1; i < tabCount; i++)
    {
        TabPage tb = tabControl1.TabPages[1];
        Console.WriteLine(tb.Name);
        TheTabPages.Add(tb);
        tabControl1.TabPages.Remove(tb);
    }
}
So, taking Sergey's excellent design suggestion of using a TreeView as a navigation tool for a hierarchy, and using Panel elements for each "node" of a hierarchy, you could associate ... using a Dictionary, for example ... Panels with TreeNodes, or a collection of Panels with TreeNodes that have child-nodes. I've done this myself.

My choice would be to define a UserControl for each UI to be displayed inside a selected Tab in a TabControl. I would define template UserControls containing common UI elements, and then create other UserControls that inherited from those templates.

So my application object graph might look like this:
Form MainForm
	TabControl TabControl1
	TreeView TreeView1
	Other UI Elements
Other Forms ...
	
UserControl UCBase
	UserControl UCTemplate1 inherits from UCBase
		UserControl UCT1Child1 inherits from UCTemplate1
		UserControl UCT1Child2 inherits from UCTemplate1
	UserControl UCTemplate2 inherits from UCBase
		UserControl UCT2Child1 inherits from UCTemplate2
		UserControl UCT2Child2 inherits from UCTemplate2


There are other ways you could represent a hierarchy within TabPages:

1. Put a Menu inside each TabPage, use nesting in the Menu to determine which Panel of a collection of Panels inside the TabPage is visible.
 
Share this answer
 
v2

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