Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Anyone understand events when clicking outside a grid?
Message
 
 
To
28/09/1998 09:35:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00141362
Message ID:
00141464
Views:
27
>>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

yes i have been working on validating grid contents before leaving the grid. i tried something you sent me before: an example about validating if the textbox.valud must be > 100.

textbox interactivechange
thisform.lhangingvalid = (this.value < 100)

grid valid
return !thisform.lhangingvalid

got it to not take focus from the grid if the activecell was in erorr. but it did not execute my column1.text1.valid, so i did not get the error message.

was trying lastcontrol.valid from the grid.valid this weekend (same idea as yours except i keep the valid control in lastcontrol). i never got it to work properly. it seemed like sometimes i went through the activecells valid twice. the first time it was not from grid.,valid. and in my column1.text1.valid i reset the invalid contents to its previous value. so the second time through (from the grid.valid), the column1.text1.valid there were no errors. do not know if it is because i put messageboxes everywhere or if i was just getting crazy from trying so many things. tried it again today and it seems to work. i am going through the column1.text1.valid only once, from my grid.valid call..

why in grid.valid do you not "return =.valid"? just wondering because that is what i tried on one of my attempts that did not work.

many thanks - brenda
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform