Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Work-a-round for shifting TabPages on Windows form Tab control

Controls

Work-a-round for shifting TabPages on Windows form Tab control

by  SBendBuckeye  Posted    (Edited  )
When you use a Tab control in a .Net Windows form and then change the TabPage order using the items property, it does not always display properly. This is a known and documented bug which has not been fixed.

I ran into it recently and found a handful of solutions, the best of which seemed to be adding the TabPages into the Tab's controls array manually when the form loaded:
Code:
'Assumes a tab control named tc and 4 TabPages
tc.Controls(0) = tabPage0
tc.Controls(1) = tabPage1
tc.Controls(2) = tabPage2
tc.Controls(3) = tabPage3
I set the index value in the Tag property and then ensured the correct order by doing something like this:
Code:
Dim index As Integer
For Each tp As TabPage In Me.tc.TabPages
    index = CInt(tp.Tag)
    Me.tc.TabPages(index) = tp
Next
Enjoy!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top