General information
Category:
Coding, syntax & commands
>>focus is in the grid. client clicks outside the grid onto another control on the form. would like to validate the activecell's contents. got some notes from cetin that i am working on to validate the grid contents. but it is bothersome that i do not understand vfp sequence of events for this. turned on event tracking of the debugger, but it seems screwy. the activecell valid is never triggered, yet i get my error message. tried executing the lastcontrol.valid from the when, but does not behave as expected. anyone understand the events, or have any ideas on this?
>>
>>thanks - brenda
>Hi Brenda,
>I think notes were about interactivechange and beforerowcolchange.
With a statistics of controls I use, it's like that I'm a grid fanatic :) Still though, I find it rather complex, events execution order and grid behaviour. Instead this is what I find to be simpliest to validate columns :
>DEFINE CLASS grdvalidate AS grid
Name = "grdvalidate"
*-- Control losing focus
PROTECTED lastcontrol
PROCEDURE BeforeRowColChange
LPARAMETERS nColIndex
* Save control ref that's losing focus as txt
this.lastcontrol = "this.columns("+ltrim(str(this.activecolumn))+ ")."+;
this.columns(this.activecolumn).currentcontrol
ENDPROC
PROCEDURE Valid
with evaluate(this.lastcontrol)
lCanLeave = .valid() && Explicitly call valid of control
endwith
return lCanLeave && if control.valid returns .f. do not let grid lose focus
ENDPROC
>ENDDEFINE
>Of course this one assumes validation code is in "currentcontrol" and should be polished for other cases (ie: dynamicurrentcontrol used and valid code is there). But so few ppl use dynamiccurrentcontrol (I think). And also doesn't deal with extra cosmetics like selectall for control when validation return .f. At last it's a simple class demonstrating grid.control.valid could work when clicked outside too.
>Cetin
a related question. lets say have row level valiation. identify a rowchange (via you mdow, and keypress logic) in beforerowcolumnchange (brcc). if rowchange then do validations and nodefault. will that work for clicking off the grid? does nodefault in the brcc keep focus from shifting outside the grid, or must i put that logic in grid.valid and return .f.?
brenda
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only