A TIP: Setting .ItemIndex does not send keyboard focus to a radio element, I know how to fix it, read on.
Instead of selecting the radio code in the radio group by installing .ItemIndex , it is much better to do this by sending focus to the radio element; just to be very clear: I mean sending focus only to radio control, and not to the entire group of radio stations.
Instead: radiogroup.itemindex:=TheIndex;
Do it like this: TRadioButton(radiogroup.Controls[TheIndex]).SetFocus;
The radio point will be selected and send it the keyboard focus , so it will display a dotted rectangle as if the user clicked on it.
Note 1. To see it in action, use the arrow keys and compare the action only with the .ItemIndex setting and sending focus to the radio node.
TRadioButton(radiogroup.Controls[TheIndex]).SetFocus; : If you use TRadioButton(radiogroup.Controls[TheIndex]).SetFocus; , then there is no need to install .ItemIndex at all, this will also be done.
We hope this helps someone having the same problem as me when you need to install it by code, for example, to avoid a circular keyboard, for example, to make it stay on the last element of the radio when the last element of the radio station is selected and right keyboard cursor pressed, same for first.
z666zz666z
source share