37

I have a TabControl which I have designed in the VS2005 designer that has about 7 tabs.

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.

CJ7
  • 22,579
  • 65
  • 193
  • 321

3 Answers3

66

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.

Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
23

Mark the TabControl in the Designer.

In the Properties Window (F4) you have a TabPages Property. You can open a new Window where you can reorder the TabPages.

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
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
  • `TabPages.Insert` is what I was looking for. I don't understand why they didn't overload the `Add` method for this. – Himanshu Oct 10 '19 at 09:49
  • @hims056 Thats because `TabPages` is a collection that implements `IList` interface. Every class that implents `IList` has an `Add` method to add an item to the end of the list and and an `Insert` method to insert an item at a specified position. This makes the framework consistent. You can make an extension method if you prefer to overload the Add method instead `public static void Add(this IList list, int position, object Item)` – Jürgen Steinblock Oct 17 '19 at 06:55
0

Open FormName.Designer.cs.

Find the line this.tabControl1.Controls.Add ....

You can change the order here.

Screenshot