Link to home
Start Free TrialLog in
Avatar of WickedDancer
WickedDancer

asked on

How do I re-order tabs on a tab page dynamically?

I have a form with a tabcontrol on it that is inherited by other forms.  The inherited forms sometimes will add tabs.  Currently, any tabs that are added are tacked on to the end, but what I would like to do is INSERT them between the two existing tabs.  I tried editing the tab order in the designer, but that doesn't work.  I presume that is due to the fact that the InitializeComponent for the base form is executed prior to the inherited, and that appears to be the sole determinant of the tab order.  I could not find an "Insert" method for TabPageCollection.  Any suggestions?

Thanks!

Greg
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Item is the indexor for the collection ... you can add and then reorder them.
Avatar of Éric Moreau
You can clear the TabPages collection and recreate it without affecting tabpage's content:

        With Me.tabParticipant
            With .TabPages
                .Clear()
                .Add(Me.tabMain)
                .Add(Me.tabOther)
                .Add(Me.tabAddress)
            End With
        End With

TabParticipant is my Tab Control
TabMain, tabOther, tabAddress are my tabpages.
ASKER CERTIFIED SOLUTION
Avatar of philippe_leybaert
philippe_leybaert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of philippe_leybaert
philippe_leybaert

WickedDancer : Any particular reason why this solutions was awarded a "B" grade ? Didn't it solve your problem? If not, why didn't you ask more questions?

Avatar of WickedDancer

ASKER

Sorry, I misunderstood the meaning of the grades.  I thought it was relating to the complexity of the problem/solution and not the validity or completeness of the answer.  Can I fix that?
I have no idea :-)  It's not that important, I was just wondering if it didn't solve your problem...