So it all started when I saw an interesting tweet:
I clicked through and read the details on the Microsoft Connect website - and it related to a Visual Studio function that I’ve used literally hundreds of times: editing the tab order of controls in WinForms.
So I tweeted back, somewhat provocatively:
It’s not a bug when the user doesn’t bother to learn how the tool works. Could it be better? Sure. Is it broken. No.
But, explaining why it’s not broken is too much of a challenge for 140 characters - so I figured I’d blog it.
Firing up Visual Studio, I created a demo form with some control nesting:
Note the document heirarchy shown on the left - this is important.
View|Tab Order …
Then, I clicked on the following items in this order:
Label “Full Name”
Text box to the right of “Full Name”
Label “Family Name”
Text box to the right of “Family Name”
Label “Known As”
Text box to the right of “Known As”
To end up with this state:
View|Tab Order to finish.
Did this give me the order I wanted? Yep.
But what’s with the decimal numbers, isn’t Tab Order an int?
TabOrder property isn’t used to order controls within a form. It’s used to order controls within a common
Have a look at the top screenshot again - there’s a reason I included the “Document Outline” view in the sidebar.
Controls nested within a common parent must be adjacent in the tab order - this isn’t a limitation of Visual Studio, nor of .NET, but of Windows itself.
The “decimal values” shown by the tab editor are trying to show you how the nesting of controls will interact with the
TabOrder values to give you the final result. The “1.0.2” shown over the “Male” radio button is showing that the
groupbox has tab order “1” within the form, the nested table layout panel has tab order “0” within the groupbox, and the
radiobutton has tab order “2” within the table layout panel.
In my demo form, there is no way I could set the tab order to the order Full Name, Family Name, Demographics, KnownAs - it’s just not supported by Windows.