Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dedecting grid row change in beforerowcolchange event
Message
From
25/09/1998 16:05:23
 
 
To
22/09/1998 03:16:52
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00139150
Message ID:
00141012
Views:
45
>>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,
Of course, you can run any grid methods from grid valid and grid valid fires
always. My problem is that I don't want to execute afterrowchange() at this
moment procedures since actually row may be incomplete and user wants to
continue its editing.

I want the user to stay in the current row of the grid after he activates
other window and click to random row in grid, without checking
ruleexpression or other things.
I think this is a required feature in a generic data entry grid class.

Currently I implemented this in a bad way:

add a custom property lChangeDisable to grid with initial value 0

* in grid valid event:
if AT('2', GetFldState(-1, this.recordsource ) )>0 or ;
AT('3', GetFldState(-1, this.recordsource ) )>0 or ;
AT('4', GetFldState(-1, this.recordsource ) )>0
this.lChangeDisable = 3 && if activating textbox outside of grid, need ignore 3 times
endif

* in grid beforerowcolchange:
if this.lChangeDisable>0
this.lChangeDisable = this.lChangeDisable - 1
nodefault
return
endif
.. your code follows

This code works but it causes some necessary clicks or keypresses to be ignored.

If your class does this I'm interested of its testing. In this
case, can you send it to we with e-mail?

Have you changed something in row highlighting method?
Some time ago I tested your grid row highlighting class but was finally not
able to use it.
I had a form with master grid A and child grid B.
Sometimes, when user uses only a mouse to do different things, a highlighted
row in a master grid does not correspond to child table rows shown in screen:
it seems that at some point grid stops refreshing its dynamicbackcolor.
But interestingly, when any key was pressed from keyboard, correct row was
immediately highlighted. This problem occurs even more frequently if there
were 3 grids in a form. Grid B was child on A and grid C was child of B
This was very confusing to my users and I was not unable to reproduce this,
it occurs randomly. Finally I switched to using recordmark property.
Also, it seems than row highlighting works to slow in 120 MHz notebook computer.
Screen was locked by lockscreen for a long time.
I tested both your earlier standard message example and your later
highlighting grid class and their behavior was same.

Also, I deducted from your message to Kamal that you want to use this.value=this.value
to flush column controlsource. VFP 6 framework uses this method also.
However, I have a combobox where user enters name and which stores actually
a code to controlsource. In this case, this.value=this.value will not refresh
controlsource, but .setfocus() does it.
Andrus
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform