>Okay, gang, here's one for your collective gray matter...
>
>I have a two-column grid with a RightClick event that pops up a shortcut menu which, among other selections, allows the user to add a new row. The grid is *normally* read only.
>
>When the row is added, I add a record to the view (optimistic table buffering) and make the grid read/write. The user needs to enter both fields (a code and a description) for a valid entry. Additionally, there's a "Close" button which could be clicked to destroy the form, so I must check for either a blank code or blank description and delete any row in the grid (the user can edit a row also) with an empty value in either column.
>
>To enforce this, I placed some code in the BeforeRowColChange event which checks for the blank values, deletes any with blanks, and sets the grid back to read-only.
>
>HERE'S THE RUB: I don't want this code to fire when I change *columns*, just when I change *rows*. The BeforeRowColChange event tells me the *column* I just left with the nColIndex parameter, but not the *row*, and there seems to be no way to determine both the row I'm leaving and the row I'm entering. Additionally, the BeforeRowColChange event fires when I move between *columns*, which turns the grid to read-only...and only allows the user to enter either the code *or* the description, but not both.
>
>How the @#$%^&* do I do this??? (g)
>
>TIA
>
>Evan Pauley
Evan,
Unfortunately it's rowcolchange event and occurs whichever you change. But as a workaround you can check lastkey() to see if it's a row change or colchange. Well code speaks better :
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
else
endif
Now extending the code a bit you would also know to which row you're attempted to go too. Also this code works with you ever use mouse or keyboard to go.
Cetin