Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid Control - detecting row change - Row level validati
Message
De
02/01/2002 18:33:46
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00599898
Message ID:
00600024
Vues:
21
The method described in message #590652 is similar to how I was attempting to do record level validation to start with. This method exhibited the same recursive calls to the validation function as the one I was using. In my validation method there are required fields that the grid will allow the user to skip. if the record is not valid, I pop up a modal wizard form that tells the user what is wrong with the record and provides suggestions and picklists to allow the user to complete the record. If the record tests as valid and does not have to pop up the modal form, it works OK, but when the wizard form pops up, it causes recursive calls to the validation method and the wizard keeps popping up until you revert the changes or kill the form with the grid. This appears to be something to do with the grid losing focus and regaining focus after the wizard form ends.

Trying to step this in the debugger caused even more recursive calls. It appears that the .AfterRowColChange is being executed each time that the grid receives focus after the modal form ends and the code line

Refer to code examples in message #590652

IF .nRec2Validate # lnRec2GoTo

was causing the problem with recursive calls.

I modified the code in AfterRowColChange to reset .nRec2Validate to 0 to prevent the code from executing recursively when a modal form is called ffrom the grid.ValidateCurrentRow(). This seemed to work well in either case.

This is the slightly modified code that I used in AfterRowColChange event:
LOCAL lnRec2GoTo
WITH This
	*** If there is no record to validate or recursive call, exit stage left
	IF .nRec2Validate =  0  
          exit
        endif


	*** Save the current record number in case we have changed rows
	lnRec2GoTo = RECNO( .RecordSource )

	*** Check to see if the row has changed
	IF .nRec2Validate # lnRec2GoTo
	*** We are validating the row we are attempting to leave...set the flag
		.lValidatingRow = .T.
		*** Return to the record we just left
		GOTO .nRec2Validate IN ( .RecordSource )
		*** If it checks out, let the user move to the new row
		IF .ValidateCurrentRow()
			GOTO lnRec2GoTo IN ( .RecordSource )
			.RefreshControls()
		ENDIF
		*** Finished with validation...reset flag
		.lValidatingRow = .F.
		.nRec2Validate = 0
	ENDIF
ENDWITH 
Resetting .nRec2Validate = 0 solved my recursive calls problem.

I thought I woulld pass this along. Many thanks for the quick reply.

Elmer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform