Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmitacally Disable text boxes
Message
From
06/08/1999 21:38:25
 
 
To
06/08/1999 08:02:29
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00250597
Message ID:
00250995
Views:
10
>I have created a form where some fields are dependent on user input. Based on the users input, I want to programmitacally disable some fields. I can move around them with setfocus() events, but that doesn't stop the user from clicking on the fields.
>
>Any Ideas.
>
>TIA.
>
>Rob




Hi, I do this as follow:

At Form Menu, Create 2 new Procedure at Form: say WhenAdd, AfterAdd

* ThisForm.WhenAdd
ThisForm.CmdTop.Enabled = .F.
....
ThisForm.CobKey1.Enabled = .F.
....

* ThisForm.AfterAdd
ThisForm.CmdTop.Enabled = .T.
....
ThisForm.CobKey1.Enabled = .T.
....

* ThisForm.CmdAdd.Click

#Define CAPADD [Add New]
#Define CAPCOM [Complete Add]
#Define CAPUPD [Update Now]
#Define CAPCAN [Cancel Add]

IF This.Caption = CAPADD
* Add record code here
This.Caption = CAPCOM
ThisForm.CmdUpdate.Caption = CAPCAN
ThisForm.WhenAdd
ThisForm.TxtStartFocus.SetFocus && Sure it won't go wrong place!!
ELSE
* Complete Add Code here
This.Caption = CAPADD
ThisForm.CmdUpdate.Caption = CAPUPD
ThisForm.AfterAdd
ENDIF

* ThisForm.CmdUpdate.Click

#Define CAPADD [Add New]
#Define CAPCOM [Complete Add]
#Define CAPUPD [Update Now]
#Define CAPCAN [Cancel Add]

IF This.Caption = CAPUPD
* Update record code here
* No Change in CAPTION!
ELSE
* Cancel Add Code here
This.Caption = CAPUPD
ThisForm.CmdAdd.Caption = CAPADD
ThisForm.AfterAdd
ENDIF




So, when user click Add new, 2 button Caption trigger and either User complete or cancel,
Trigger back!!

It will more easy to handle and you can make those two buttons as Class.. ^_^;

Then, even you can add a short-cut at Form to further add record especially for Grid!
e.g. call the click twice if it's CAPTION is CapCOM

* ThisForm.KeyPress
Lparameters nKeyCode, nShiftCtrlAlt
#Define CAPCOM [Complete Add]

Do case
case nKeyCode = -8 && F9 is press
NoDefault
If ThisForm.CmdAdd.Caption = CAPCOM
* Complete Add, of cos you need to Auto-Feed the Common key at Add New Code
ThisForm.CmdAdd.Click
* Add New Again, Going to add next OrdItems etc.
ThisForm.CmdAdd.Click
Endif
ENDCASE




You can maintain the system very comprehensive if you divide them OOP and
Clear Case Division!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform