WinForm - TabStop not working

I have WinForm with 3 group boxes, one with combo boxes and two with radio buttons. I set all of them and their child controls to "TabStop = false", but when I switch from TAB, the currently selected switch in each of the last two group blocks is focused.

If there is no way to change this behavior, what would be a good event to catch and shift focus? I can not find the OnFocus event.


The solution is to set up one method (code below) to handle the "Enter" event of each switch in the form (if necessary).

In fact, I only did this for the switches in the first group field, and it worked, and the switches of the second group field do not focus, although their "Enter" events are not processed. This is not the behavior you expected.

private void radiobuttonXGroup1_Enter(object sender, EventArgs e)
{
   SomeOtherControl.Focus();
}

In the * .Designer.cs file, you edit each Enter event (for each switch) to point to one event handler (the above method).

this.radiobutton1Group1.Enter += new System.EventHandler(this.radiobuttonXGroup1_Enter);
this.radiobutton2Group1.Enter += new System.EventHandler(this.radiobuttonXGroup1_Enter);
this.radiobutton3Group1.Enter += new System.EventHandler(this.radiobuttonXGroup1_Enter);
+3
source share
2 answers

The MSDN documentation for RadioButton.TabStop states: "This API supports the .NET Framework and is not intended to be used directly from your code." Which basically means: "It will not work as you expect."

, Enter , . , .

+5

TabStop False RadioButton, , - , , @msergeant.

:

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
   radioButton1.TabStop = false;
}

- - , .

+5

Source: https://habr.com/ru/post/1761384/


All Articles