Information générale
Catégorie:
Programmation Orientée Object
Hi John,
This is something I got from in the "Effective Techniques..." book or the "Fundatmentals..." book (I don't remember which) as well as a post on another newsgroup a couple of months ago. This particular piece was put in the Valid event of a textbox control subclass.
LOCAL llRetVal, ;
loObject
llRetVal = .T.
*----------------------------------------
* Over what object is the pointer sitting
*----------------------------------------
loObject = SYS(1270)
*------------------------------------------------------------------
* If the last key pressed us Escape or SHIFTTAB (defined in an include file)
* or a custom property of the object exist and is (in this case)
* true or clicked on the form close skip validation
*
*
* PROBLEM: ShiftTab with invalid data in the control and then click save
* can result in invalid data in the tables. It is up to you
* to have validation (business rules) checking prior to
* the saving.
*------------------------------------------------------------------
IF (INLIST(LASTKEY(), KEY_ESCAPE, KEY_SHIFTTAB) OR ;
(TYPE('loObject.lCancel') = 'L' AND loObject.lCancel) OR ;
(TYPE('ThisForm.ReleaseType') = 'N' AND ThisForm.ReleaseType > 0))
RETURN .T.
ELSE
RETURN This.isValid() && Put validation criteria in a custom method for the control
ENDIF
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement