Question Restricting TABSTOP

webbiz

Member
Joined
Oct 15, 2011
Messages
21
Programming Experience
10+
I have a form with four text boxes and a group of radio buttons.

I've restricted the tab stop to only two of the text boxes.

Using TAB, I want to only tab between these two text boxes.

Unfortunately, the selected radio button is also tabbed to when pressing TAB.

While the text boxes each had a property that could be set to FALSE to prevent getting the focus on TAB, I was not able to find this for the radio buttons.

How do you restrict TAB from giving the radio button focus?

Thanks.
 
RadioButton.TabStop property is infrastructure and is set dynamically at runtime to allow tabbing directly into checked radio and out of radio group again.
The best option to prevent tabstopping to radiobuttons is to select Enter event handler for all radios and call SelectNextControl method to auto select next control in tab order.
 
Within the ENTER event handler I added the following:

Control ctl;
ctl = (Control)sender;
ctl.SelectNextControl(ActiveControl, true, true, true, true);

This I found in the MSDN site since I've never used SelectNextControl before.

It did not bounce the focus back to the next control. Nothing appeared to happen.

I'm searching for more info on this method but right now I'm still not sure what is wrong.

Thanks.
 
Okay, found the correct way to use this.

Control ctl;
ctl = (Control)sender;
this.SelectNextControl(ctl, true, true, true, true);

This works!

Thanks for the heads up.

:)
 
Back
Top Bottom