Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
When I give the focus to an option button (radio button) by setting its SetFocus property to true, the option button not only gets the focus but also gets selected (i.e Value property turns to true).
Is there a way to just give the focus to the option button but keep the original value of the radio button.
PS: The option buttons are in a group and I gave the focus to the first button in the group.

Depends if the Option buttons for a Control Array. If they do, and they should, the following code will retain the previous option.
Dim a As Integer
Dim OptValue As Integer
For a = 0 To 2 'Number of Option buttons. The first one is 0.
If Option1(a).Value = True Then OptValue = a
NextOption1(OptValue).SetFocus
Stuart

Nope. That doesn't help. What is exactly needed is a way by which the dotted rectangle (focus) comes around the first option button in the control array but the button itself does not turn on.
SetFocus sets it to true and and so the first option button gets selected even though we just wanted to give it focus.This behavior is not seen on HTML radio (option) buttons. You can give the focus to an HTML radio button without setting to on.
Thanks

What you are trying to do will not work. Option buttons do not work the way you describe.
Whats the point of giving an Option button with foucus and not making it selected. Its against the principle of what option buttons are for.
If you want a button to have focus and not be selected you need to use the check button. But then you lose the facility to only have one option checked in a group.
Stuart

I agree it is hard to imagine such a situation. Let me explain my problem. The option buttons are answers to some questions on a tab pane of SSTab control, and the user cannot proceed to the next tab unless he/she selects the answer to one particular question.
To quickly let the user know where he/she needs to answer the question without actually selecting the answer, I would like the focus to shift to the first option button for that questions answer.Now, this is the way it is being done on the web site version of the application, and so I wanted the two interfaces to be consistent.
Phew!The answer to this problem may very well not be an easy one. I guess it still can be done using Windows API calls. But could anyone help or direct me in the right direction.
Thanks

In that case, the only way you are going to do what you describe is to un-group the option buttons. You will then have to maually check that only one option button is ever selected which I assume is what you want.
I think you need to be looking at the check button. This will do what you want. An option button is checked as soon as it gets focus. This is the way it is meant to work. No API is going to overide that beaviour.
Stuart

You could put a "dummy" option into each group, that is visible but somewhere out of sight, and selected by default. If any of the dummy options are selected when the user submits, then you can cancel it (because you know that one of the fields has not been filled out).
-Burbble

Tried this too. Works normally as it should. Not in my case. Anyways thanks for your replies.

![]() |
WPCTRL.DLL File missing
|
Programming in C
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |