Greetings guys i'm stuck with this problem last night and until but i can't find any solution.

Every time i add a tabpage from my tabcontrol in runtime it's not in right order

i have 1 tabpage in my tabcontrol and when i add another page it goes perfect but if i add another it goes like this

Add 1 tabpage: tabpage1, tabpage2
Add another : tabpage1, tabpage3, tabpage2
and if i add another: tabpage1, tabpage4, tabpage2, tabpage3

is there a code that will arrange the tab in-order?

Recommended Answers

All 4 Replies

Please show us the code you use to add the tabpage otherwise we are just making uninformed guesses as to what the problem may be.

This is the code that adds the page.

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim TabPage As New TabPage
        TabPage.Text = "Day " & TabControl2.TabPages.Count
    End Sub

Your code should not be generating the problem you are seeing. I was expecting to see you using the TabPages.Insert method. Per the documentation:

The order of tab pages in the TabControl.TabPages collection reflects the order of tabs in the TabControl control. To change the order of tabs in the control, you must change their positions in the collection by removing them and inserting them at new indexes.

The only thing that I can think of is that your memory has somehow been corrupted. When was the last time that your performed a reboot? It's worth a try to see if remedies the problem.

What VB version are you using? 2010, 2012 or something else? If it is 2012, try target .Net 3.5 or 4.0 instead of 4.5. In another thread, we discovered some atypical behavior from 4.5.

Sorry, I can't be of more assistance, but that just should not be happening.

Darn, But thank you sir for the help :D.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.