Focus of RadioButton

J

jahuer1

On my Form I have several Panels with several RadioButtons on it. When
I start the Form, on each Panel a RadioButton should be selected if
it was selected when I called the Form some time ago.

Problem:
How can I force that the focus remains on a specific RadioButton after
it is selected? (so that also the text is surrounded by the dotted
line as it is the case when you reach a RadioButton by TAB).
At the moment the focus goes away after selecting and resides on some
father component.

Attention:
I do have to rebuild the Form dynamically every time a RadioButton is
clicked because depending on a click the appearance of the Form may
change!
 
R

Russell Jones

Save the current settings of the RadioButtons on the form in a file in the
local user's data folder (see the Application.LocalUserAppDataPath property)
before closing the form, and read those settings when the form opens. You
can include a value that lets you know which (if any) of the RadioButtons
has the focus. The first time the form runs for any given user, the file
won't be there, so you'll need to handle that condition (or other errors
during the read), and display the form in its default configuration.

jahuer1 said:
On my Form I have several Panels with several RadioButtons on it. When
I start the Form, on each Panel a RadioButton should be selected if
it was selected when I called the Form some time ago.

Problem:
How can I force that the focus remains on a specific RadioButton after
it is selected? (so that also the text is surrounded by the dotted
line as it is the case when you reach a RadioButton by TAB).
At the moment the focus goes away after selecting and resides on some
father component.

Attention:
I do have to rebuild the Form dynamically every time a RadioButton is
clicked because depending on a click the appearance of the Form may
change!
 
J

jahuer1

Well this is not really the point. I do save my configuration and then
enter my form with:

dim QForm as new Form
QForm.initTheForm(mySettings)
...etc.

The point is that after I set the right RadioButtons, the focus goes
away:
(in initTheForm):

for i=0 to myPanels.GetUpperBound(0)
with myPanels(i)
for j=0 to .radiobtns.GetUpperBound(0)
if mySettings(i,j) then
.radiobtns(j).checked=true
endif
next
end with
next

On my point of view, focus should remain on the last RadioButton that
"checked" was set to TRUE. But it isn't. It seems as it is on the
father Panel of this RadioButton. At least it surely does not look
like as if I enter the Panel after some TAB's. Only then it is really
focused and the dotted grid-line appears.
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed)-spam.invalid (jahuer1) scripsit:
[...]

Why not address your posts to everybody in this group? For private
communication, use email.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top