Change the Order of TabPages in a TabControl in C#

There seems to be no way to easily change the order of TabPages in a TabControl in C#.

If there is a way to visually re-order them, then I can't find it.

However, some sources seem to suggest that the only way to do it are to move the controls off the TabPage, put them somewhere safe, then delete and re-add the TabPage to the TabControl.  I don't like this approach, through - I don't want to delete anything.

I think I found a way around this, but requires some careful editing of files.

If your form is called MyForm, you should have 3 files in the solution's folder :-

MyForm.cs
MyForm.Designer.cs
MyForm.resx

Open MyForm.Designer.cs in NotePad (or similar)

Locate the line where your TabPage is instantiated :-

this.pagWantThisAsLast = new System.Windows.Forms.TabPage();

and move it below the other TabPage() items.

The form will create them in that order.

Comments

Popular posts from this blog

Morrisons Three Fish Roast

Get Friends and Family to Record Onto Your Yoto

How to Stop the Annoying Nag Message in Outlook Asking to Take Outlook Anywhere