Tab order of radio buttons .Net 1.1

February 25, 2009 at 09:57:14
Specs: Windows XP, 1GB
Hello guys,

I've been working on getting the tab order of radio buttons on my windows form right...but something just seems amiss.

I've got a simple windows forms application (VB.Net on the 1.1 framework) with two panels on it. Say Panel1 and Panel2.
Panel1 has two radio buttons(say radiobutton1 and radiobutton2) and so does Panel2(say radiobutton3 and radiobutton4). In addition there is a "Clear" button, which sets the checked property of all the radio buttons to False.

The tab control is set as follows
Panel1 (0)
Radiobutton1 (0)
Radiobutton2 (1)

Panel2 (1)
Radiobutton3 (0)
Radiobutton4 (1)

When the form loads the focus is on Panel1's radiobutton1.On Tab, Panel2's radiobutton3 is checked. This is expected behavior.

When I select the "Clear" button all the radio buttons are cleared, however, i am now unable to tab around. i.e. my tab seems to be lost and I am unable to get focus onto any of my panels or radio buttons within the panels.Anyone out there got any ideas about how I can fix this...or why this happens?

Any help will be appreciated.

See More: Tab order of radio buttons .Net 1.1

Report •

February 26, 2009 at 21:08:08

Hi lavanya,

This is expected behaviour from radiobutton of dotnet1.1 framework,
Becuse when you are clicking on clear and setting Radiobuttons checked property to false
as Radiobutton.checked=false ,
due to this Radiobuttons TabStop property turns to False.

What TabStop property does?
>>Indicates whether the user can use The TAB key to give the focus to control.

Becuse it is turned to False ,There is no control on panel which have TabStop property to true or you can say that (there is no active control on panel to set next focus).

There are two solution for this issue:

Solution :1 You can set TabStop property of radiobutton to true after setting Radiobutton.checked = false;

like as below:

private void clear_Click(object sender, System.EventArgs e)
radioButton1.Checked = false ;
radioButton2.Checked = false ;
radioButton3.Checked = false ;
radioButton4.Checked = false ;

radioButton1.TabStop =true;
radioButton3.TabStop =true;


Solution:2 You can set radiobuttons AutoCheck property to false before setting Radiobutton.checked = false

What AutoCheck property does?
>>causes the radio button to automatically change state when clicked.

when you use then by default its state turns to Checked.
thts why if we set AutoCheck prperty to false then it will not change radiobuttons state to checked and maintain its taborder.
But this is not enough to acheive its proper behaviour of checked when it will get focus,
for that we have to manually set AutoCheck() to true when panel got focus.

like as below:

private void clear_Click(object sender, System.EventArgs e)
radioButton1.AutoCheck= false;
radioButton2.AutoCheck= false;
radioButton3.AutoCheck= false;
radioButton4.AutoCheck= false;

radioButton1.Checked = false ;
radioButton2.Checked = false ;
radioButton3.Checked = false ;
radioButton4.Checked = false ;


private void panel1_Enter(object sender, System.EventArgs e)
radioButton1.AutoCheck= true;
radioButton2.AutoCheck= true;

private void panel2_Enter(object sender, System.EventArgs e)

I will suggest to use Solution :1

Any new solution rather than this would be appreciated

Report •
Related Solutions

Ask Question