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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need code to compare optionboxes to enable textboxes

Status
Not open for further replies.

stevens

MIS
May 12, 2000
10
0
0
US
I am creating a form with four optiongroups and two textboxes.<br>I want to be able to check the value of an optionbox in an optiongroup when I click on an optionbox in a different optiongroup that will determine which textbox to enable.<br>Does anybody have any code that will help me.&nbsp;&nbsp;<br>I also want the form to automatically determine the values of the default optionboxes so that the enableing of textboxes and other options can be done upon initialization.&nbsp;&nbsp;I know this goes in the init event.&nbsp;&nbsp;I just need a code sample.<br>Thanks
 
There are several ways to do this.<br><br>1) You could add code to the Valid event of your check box to enable/disable the textbox<br><br>2) If your writting the classes you could add an assign procedure to the control variable.&nbsp;&nbsp;This is sometimes preferable, because you can then change the check boxes programatically too and the textboxes will update themselves<br><br>Say your form has a property <b>Statewide</b>...<br><br>&nbsp;&nbsp;PROCEDURE StateWide_assign<br>&nbsp;&nbsp;&nbsp;&nbsp;LPARAMETERS vNewVal<br>&nbsp;&nbsp;&nbsp;&nbsp;thisform.StateWide = vNewVal<br>&nbsp;&nbsp;&nbsp;&nbsp;IF vNewVal = 0 THEN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;thisform.txtWhichState.enabled = .F.<br>&nbsp;&nbsp;&nbsp;&nbsp;ELSE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;thisform.txtWhichState.enabled = .T.<br>&nbsp;&nbsp;&nbsp;&nbsp;ENDIF<br>&nbsp;&nbsp;&nbsp;&nbsp;thisform.refresh<br>&nbsp;&nbsp;ENDPROC<br> <p> <br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>
 
My .02-<br><br>In the Form Refresh event:<br><br>This.Text1.Refresh()<br>This.Text2.Refresh()<br>*This isnt absolutely needed because the form will refresh these controls whether this code is here or not..but it's a good technique to explicitly refresh the controls that have code in their refresh event for easier future maintenance.<br><br>In EACH option button's click event:<br><br>Thisform.Refresh()<br>*notify the form that something happened and it needs to refresh it's contained controls<br><br>In Each Text box's refresh event:<br><br>This.Enabled = (ThisForm.OptionGroup.Value = 2)<br>OR<br>This.Visible = (ThisForm.OptionGroup.Value = 2)<br>*or whatever condition is used to determine if the textbox is enabled/visible<br><br>I always advise against this:<br><br>In option button's click event:<br>Text1.Visible = .T.<br>OR<br>Text1.Enabled = .T.<br><br>because once your procedures begin filling up with code, it is harder to track down bugs using this technique. <p>Jon<br><a href=mailto: > </a><br><a href= > </a><br>Carpe Diem!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top