Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Group Issue for a newbie

Status
Not open for further replies.

DNA2Fly

Technical User
Oct 18, 2008
2
US
Newbie to VFP. How do I take an option group (such as a Yes/No question would use) and:
1. If "Yes" selected, activate a text box/list box/other
2. If "No" selected, deactivate a text box/list box AND move to next field

Also, this applies to use in a check box....

THANKS!
 
Put this in InterActiveChange event of the OptionGroup:
Code:
*** Assuming Yes is the first option and no is the second one
thisform.TextBox.Enabled = (this.Value == 1)


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Thanks bborissov,

I'll give it a try...
 
Both are valid representations and are found in desktop and web applications. You'd perhaps prefer a Checkbox, as it's more natuaral to bind a boolean field/value to it in VFP than to an optiongroup with two options, because the checkbox may have values .t./.f. (true/false), while the option group would be 1 or 2 and you'd need to translate .t./.f. to that, but it's not very hard to do so.

Moving focus is easier with a checkbox, as it is a single control, while an optiongroup each option can have focus, so perhaps for that reason I'd also choose a checkbox, although it's easy to move focus anyway, by calling the Setfocus() method of whatever control you want to get focus next. Or by returning a number N from a valid() event to move N controls further. Or by Keyboard '{Tab}' to emulate a Tab key for moving focus.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top