如何在选项卡中插入选项卡 [英] How to insert tabs inside tab

查看:207
本文介绍了如何在选项卡中插入选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Winform上就有这样的标签,比如

Inward,Office,Dealer ,



所以我想在经销商标签内找到新的标签Outward和Account



I正在制作窗口基础应用程序。

解决方案

这将是一个非常糟糕的设计理念。标签页内的标签页可能会极大地混淆用户。如果您有两个或更多层次结构的值,或者使用两种不同的不同导航样式,或者只使用一个特别设计的(并且得到用户公认)导航元素:树视图。



这是它的外观:在左边,放置一个树状视图。在右边:一组面板(例如)一次显示一个面板;那些面板将起到标签页的作用。 (这种从左到右的布局适用于西方文化,对于使用从右到左书写系统的文化,从右到左的布局会更加充分。)



然后将所有或某些节点与右侧面板的实例相关联(如果不是全部,则某些节点将仅扮演主题标题的角色)。处理树视图的选择事件以显示右侧面板的关联实例并隐藏其他面板。每个小组都有不同的内容。不是那么简单吗?这是Microsoft Properties页面使用的设计样式,例如Visual Studio和其他更新的选项和属性窗口。



-SA

>您不能在另一个选项卡控件的页面上放置选项卡控件。我知道

>两个解决方法:

>

> 1.在选项卡页面上放置一个子窗体,并将新的选项卡控件放在

>上。子表单。

>

> 2.将新选项卡控件放在原始选项卡前面的表单上

>控制,并使用原始标签控件的Change事件来制作新的

>选项卡控件仅在原始选项卡位于所需页面时可见。





根据这些答案。

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 [ ^ ]


您当然可以将TabControl放在另一个TabControl的TabPage中,但我同意Sergey的意见,这会导致用户界面体验不佳。我已经看到一个用户界面,其中TabControl-inside-a-TabPage使用TabControl.Alignment设置为TabAlignment.Left垂直显示其Tabs:难以阅读Tabs,imho。另外,请注意,即使您将TabPage的Font'GdiVerticalFont属性设置为'true,它也没有效果(不管我尝试过的任何字体):字体不会以真正的垂直方式显示。



请记住,您可以在设计时在TabControl内创建许多TabPages,并根据需要配置其用户界面,为其控件连接EventHandlers,并在运行时时间,创建它们的集合,然后删除任何你想要的,并在需要时从集合中恢复它们。这涉及一些工作,通常不会完成,如果你是WinForms编程的新手,我建议你不要接受它,但是,它是可能的。



< b>您现在应该问的问题的答案是:是的,如果您从一个有效的TabPages集合中将已删除的TabPage恢复为TabControl,那么您为其内部控件定义的事件处理程序仍然存在,并将触发事件正如预期的那样。



例如,这将删除除第一个TabPages之外的所有TabPages,并将删除的TabPages存储在List中:

 私人列表< tabpage> TheTabPages; 

private void Form1_Load(对象发​​件人,EventArgs e)
{
TheTabPages = 列表< tabpage>();

// 必须在迭代之前执行此操作
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);
}
}

因此,采用谢尔盖的优秀设计建议,即使用TreeView作为层次结构的导航工具,并使用Panel元素作为层次结构的每个节点,可以使用词典关联...例如...具有TreeNodes的面板,或具有子节点的TreeNodes的面板集合。我自己做了这个。



我的选择是为每个UI定义一个UserControl,以显示在TabControl中选定的Tab内。我将定义包含常见UI元素的模板UserControls,然后创建从这些模板继承的其他UserControl。



因此我的应用程序对象图可能如下所示:

 Form MainForm 
TabControl TabControl1
TreeView TreeView1
其他UI元素
其他表格...

UserControl UCBase
UserControl UCTemplate1继承自UCBase
UserControl UCT1Child1继承自UCTemplate1
UserControl UCT1Child2继承自UCTemplate1
UserControl UCTemplate2继承自UCBase
UserControl UCT2Child1继承自UCTemplate2
UserControl UCT2Child2继承自UCTemplate2





您可以通过其他方式表示T​​abPages中的层次结构:



1.在每个TabPage中放置一个菜单,使用菜单中的嵌套来确定TabPage中面板集合的哪个面板可见。


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.

解决方案

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


> 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[^]


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:

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.


这篇关于如何在选项卡中插入选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆