Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using a Control (or a container) to validate its content
Message
De
30/04/1997 00:49:47
Siu-Hung Lai
The Hong Kong University of Sci. & Tech.
Hong Kong, Hong Kong
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00030015
Message ID:
00030208
Vues:
52
>>IMHO it is better to use the LostFocus
>>as it seems the valid event is only there for backward compatiility
>>and that MS tries to move us to the more (windows) standard of LostFocus
>>(e.g. not SetFocus from Valid)
>>to prevent a control from loosing focus you should put NODEFAULT in this
>>event
>>
>>btw, you can see a Date Picker control I wrote in one of the early VFUG
>>newsletters
>>
>
>BUT, the lostfocus does not work the same way as the valid event. If you place an edit box on a form and put nodefault in its lostfocus event and then place a checkbox or button on the form, the checkbox can still be checked and the command button's click event will still be called. I am trying to make each control (not just date picker controls) responsible for its valid state in such a way that if focus leaves that control there is a guarantee that that control is valid.
>
>If the Lostfocus event happened before the new controls gotfocus then nodefault would solve all the problems. But this doesn't happen. Instead the gotfocus of the new control is called (and if its a command button and it is clicked to receive focus its click event is called) before the lostfocus of the old control is triggered.
>
>The only solution I have found so far is to place code in the when event of every control on the form so that the new control will not be entered if the old Control or Container is not valid.
>
>The VFP Valid event works as expected. The focus cannot leave the control until the Valid returns .T.
>
>Hope this clarifies what I am trying to do...
>Peter

I have the same problem. My solution was to create form property(s) to hold validation status. Put validation code in LostFocus event of control(s). Toggle the property(s) base on the validation result. Put code in When event to check the validation status only. Therefore you can keep your validation code in the control you want.

HTH

S.H.
Siu-hung Lai
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform