C# 如何轻松地重新排序 TabControl?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12001502/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to easily reorder TabControl?
提问by CJ7
I have a TabControlwhich I have designed in the VS2005 designer that has about 7 tabs.
我有一个TabControl我在 VS2005 设计器中设计的,它有大约 7 个选项卡。
How can I easily switch the order of the tabs around?
如何轻松切换选项卡的顺序?
I put one tab at the end in a rush, but now I want it somewhere in the middle.
我匆忙在最后放了一个标签,但现在我想要它在中间的某个地方。
采纳答案by Paul Michaels
In the properties of the tab control there's a TabPages collection. You should be able to shuffle them around in there. Just click the ellipses next to TabPages and a dialog will appear allowing you to move each one up or down in the order.
在选项卡控件的属性中有一个 TabPages 集合。你应该能够在那里洗牌。只需单击 TabPages 旁边的省略号,就会出现一个对话框,允许您按顺序向上或向下移动每个省略号。
回答by Jürgen Steinblock
Mark the TabControl in the Designer.
在设计器中标记 TabControl。
In the Properties Window (F4) you have a TabPages Property. You can open a new Window where you can reorder the TabPages.
在属性窗口 (F4) 中,您有一个 TabPages 属性。您可以打开一个新窗口,您可以在其中重新排序 TabPage。
If you want to do that at runtime you have to do
如果你想在运行时这样做,你必须这样做
tabControl.TabPages.Remove(tabPage1);
tabControl.TabPages.Add(tabPage1); // add to the end
tabControl.TabPages.Insert(2, tabPage1); // add on specific position

