So it all started when I saw an interesting tweet:

“Broken by design”. Visual Studio - yet another product I won’t waste my time reporting any more bugs for: http://bit.ly/ewsHSO @CADbloke (RT by RoyOsherove)

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.

I selected 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”

  • Label “Gender”

  • Radiobutton “Female”

  • Radiobutton “Male”

  • Radiobutton “Unknown”

To end up with this state:

Then, 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?

The TabOrder property isn’t used to order controls within a form. It’s used to order controls within a common parent.

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.

Comments

blog comments powered by Disqus
Next Post
On Comments and Spam  01 Apr 2011
Prior Post
IIS Web Application installation trap  01 Mar 2011
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
March 2011
2011