question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Radio button "arrow order" cannot be configured

See original GitHub issue

Problem description

When I add multiple RadioButton controls to a form, they are navigated between as a group using the arrow keys instead of the Tab key. (Only the focused radio button in a group has TabStop=true.) However, the order in which the controls are added to this “arrow order” array appears to depend on the order with which they were added to the form in the InitializeComponent() method. Since the order of calls in this method cannot be manually changed (without being immediately reverted by the designer), I cannot set the “arrow order” myself. In my project, the runtime “arrow order” happens to be bottom-to-top (pressing the up arrow moves the focus to the next radio button below the currently focused button), but I believe that is due to sheer random chance. It could just as well be in a meaningless, seemingly random order.

I need a way to ensure that the “arrow order” is logically related to the visual position of the controls on the form. I don’t know what this should look like in terms of API, as (a) the ordering of a group of radio buttons needs to be independent of any other group of radio buttons on the form, and (b) this logic appears to be performed by native code, not by Windows Forms proper.

Have you experienced this same bug with .NET Framework? Have not checked, as .NET Framework is EOL.

Version info

.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.20262
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  3.0.100 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
vladimir-krestovcommented, Dec 6, 2020

@merriemcgaw, this sounds familiar maybe because of #2164 but it doesn’t relate to this issue.

  • Objects are in the order of adding in Controls property of a form in the accessibility tree. image
  • TabStop doesn’t affect the order of the arrow keys
  • @wjk, did you tried to use TabIndex property? As I see, TabIndex values affect the order of moving using the arrow keys. For example:
            // 
            // radioButton1
            // 
            ...
            this.radioButton1.TabIndex = 3;
            ...
            // 
            // radioButton2
            // 
            ...
            this.radioButton2.TabIndex = 0;
            ...
            // 
            // radioButton3
            // 
            ...
            this.radioButton3.TabIndex = 2;
            ...
            // 
            // radioButton4
            // 
            ...
            this.radioButton4.TabIndex = 2;
            ...

Or just set these values using Designer image

1reaction
weltkantecommented, Dec 5, 2020

The control order also determines the display order (which is important for overlapping controls) and is very much editable. You should be able to change the control order by “move to front” / “move to back” actions in the designer, or through the document outline view. If these no longer work thats a defect in the new designer. (I’ve not had a chance to use the new .NET 5 designer yet so I don’t know the state here.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tab index is not working on radio buttons
A radio button group has a single tab stop at run time. The selected button (that is, the button with its Checked property...
Read more >
The radio buttons are not accessible using up arrow and ...
The radio buttons should be automatically selected on navigating and also those radio buttons should be accessible using up and down arrow keys....
Read more >
Tabbing Order for Radio Buttons | Adobe Acrobat
I set the tab order like I normally do for text fields or check boxes and the tab order shows properly but when...
Read more >
Guidelines for radio buttons - Windows apps
Focus and selection after keyboard navigation, where the Down arrow key moves focus to radio button 3, selects it, and clears radio button...
Read more >
Likert tabbing order / selecting radio buttons.
If I use the arrow keys to navigate through the radio buttons, it will select the button that gets focus. This means it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found