Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Option Group question
Message
From
01/02/2007 12:24:44
 
 
To
01/02/2007 11:59:46
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01191265
Message ID:
01191451
Views:
21
This message has been marked as the solution to the initial question of the thread.
Hi Barry,

this code might do it for you in the gotfocus of the container:
WITH this.optiongroup1
	FOR EACH button IN .Buttons
		IF button.Caption = .Value
			button.SetFocus()
		ENDIF 
	ENDFOR 
ENDWITH 
>>>>>I have an option group on a form with 3 options - say "Apples","Oranges","Lemons". When a user steps into the group using the keyboard the first option always gets focus - even though another option may be the one showing the true value in the radio button. How do I get the focus to land on the option that has the true value shown by the radio button? I can't seem to see any property that allows me to do this.
>>>>>
>>>>>At present a user can step through the option group and accidentally change the selected option to the first radio button.
>>>>>
>>>>>I hope that I have explained the problem clearly enough. (A lot easier to demonstrate than to describe!)
>>>>>
>>>>>Thanks
>>>>>Barry Sutton
>>>>
>>>>Barry,
>>>>Use a container. Put the optiongroup in container.
>>>>
>>>>*Container gotfocus
>>>>WITH this.optFruits
>>>> .Buttons(max(.Value,1)).SetFocus()
>>>>endwith
>>>>
Cetin
>>>
>>>Hi Cetin
>>>I can see what your method is trying to do, but I am having a problem as the reference to .Value refers back to the value of this.optFruits rather than the .Buttons collection maximum value. I can't work out the syntax to get to the maximum value of the .Buttons.value - if you see what I mean?
>>>Barry
>>
>>No I don't:)
>>It is not trying to get maximum value of Buttons. It's just doing a max(currentvalue,1) in case value is 0.
>>Cetin
>Hi Cetin
>As I understand it Buttons is a collection in the optFruits option group and what the code is trying to do is to find which of the buttons in the collecion as a value property set to 1, or setting to 1 if they all evaluate to zero. and then setting focus to the Button which has a value property = 1.
>
>My problem is that when the gotfocus for the container runs your code:
>
> .Buttons(max(.Value,1)).SetFocus()
>
>I get an error operator/operand mismatch (as .Value is evaluating to "Apples")
>
>So I tried running:
>
>THIS.opgFruits.buttons.count
>
>but this also errors with "Buttons is an unknown member"
>
>Sorry to be a bit dim with this - but it would be nice to get it working as it is generic and will not change if I have to add in another button.
>
>Barry.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform