Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dedecting grid row change in beforerowcolchange event
Message
From
22/09/1998 03:16:52
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
21/09/1998 13:54:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00139150
Message ID:
00139381
Views:
40
>Is it possible to dedect grid row change in beforerowcolchange event using this code by Cetin:
>
>> For record level validation this is my grid class beforerowcolchange
>
>> *beforerowcolchange
>> LPARAMETERS nColIndex
>> thisform.LockScreen = this.lInGrid && Related with highlight
>> llChangingRow = .f.
>> with this
>> if mdown()
>> lnBottom = .top+.headerheight+ .relativerow * .rowheight
>> lnTop = lnBottom - this.rowheight
>> lnMouseRowPos = mrow(wontop(),3)
>> llChangingRow = !between(lnMouseRowPos,lnTop, lnBottom)
>> else
>> llChangingRow = inlist(lastkey(),24,5,18,3,145)
>> endif
>>endwith
>>if llChangingRow ;
>> and !empty(dbgetprop(this.recordsource,"Table","RuleExpression")) ;
>> and !evaluate( dbgetprop(this.recordsource,"Table","RuleExpression"))
>> nodefault
>> this.WarnMessage()
>> else
>> * Escape
>> if lastkey() = 27 ;
>> and !empty(dbgetprop(this.recordsource,"Table","RuleExpression")) ;
>> and !evaluate(dbgetprop(this.recordsource,"Table","RuleExpression"))
>> =tablerevert(.f.,this.recordsource)
>> endif
>>endif
>
>How to handle the following case:
>
>1. During row editing, user activates some other window: this is required.
>2. After that, it rapidly clicks in some other row in the editing window.
>
>This causes a number of events to occur: other window lostfocus(), deactivate(),
>editing window activate() and at last, your grid beforerowcolchange() event
>
>However, your beforerowcolchange event does NOT dedect row change in this
>case because mouse button may be already released at this moment !!!
>
>How to avoid this situation?

Andrus,
As you may have noticed from those extra PEM (warnmessage, lInGrid etc) this code is part of a grid.class code. Full code has afterrowcolchange, when, valid event code too. If another window or control is being called it means grid will lose focus (even for a fraction of second) and thus valid fires (also Esc pressed and a commandbutton might have cancel=.t.). In original class code valid calls another custom method of grid (recchange) which in turn fires beforerowcolchange before grid lose focus (if valid would return .t.).
Plus this is not the whole original code (in original I took into account user might just type a required field and hit -or click- up arrow before tab or enter, which would defeat ruleexpression evaluation in buffered table).
Furthermore if you're going to activate another window through code it means you already know you're going to change rowcol and explicitly might call it.
In summary class is a rowhighlighted, allowaddnew (Ctrl+dnarrow from any row), check table validation grid. I was baking the full code for UT\Files section. If you're volunteer to be a betatester for the class I can send it to you. No commentation (the hardest thing for me), just have testdata, put some table validation rule, change some caption and format, inputmask in DBC, then insert gridclass on your form and use VFP's own gridbuilder for the rest (just field selection). Lemme know if you wanna try it.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform