简体   繁体   English

如何轻松地重新排序 TabControl?

[英]How to easily reorder TabControl?

I have a TabControl which 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.我匆忙在最后放了一个标签,但现在我想要它在中间的某个地方。

In the properties of the tab control there's a TabPages collection.在选项卡控件的属性中有一个 TabPages 集合。 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 旁边的省略号,就会出现一个对话框,允许您按顺序向上或向下移动每一个。

Mark the TabControl in the Designer.在设计器中标记 TabControl。

In the Properties Window (F4) you have a TabPages Property.在属性窗口 (F4) 中,您有一个 TabPages 属性。 You can open a new Window where you can reorder the 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

Open FormName.Designer.cs.打开 FormName.Designer.cs。

Find the line this.tabControl1.Controls.Add ....找到这行 this.tabControl1.Controls.Add ....

You can change the order here.您可以在此处更改顺序。

Screenshot截屏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM