1

Konu: Keypress problem

Hello:

I have a grid and textboxes in the same form. In the grid's KeyPress mehtod, I have

Visual Fox Pro
LPARAMETERS nKeyCode, nShiftAltCtrl

 
IF nKeyCode = 5 OR nKeyCode = 24     Up Arrow or Down Arrow
 
    THISFORM.txtTransfdate.Refresh
 
ENDIF


I am trying, of course, to refresh the textboxes so that they show the corresponding values that are in he grid. It does not work.

What am I doing wrong?

Regards,

Hans L.

2

Re: Keypress problem

try your codes at AfterRowColChange Event instead of Grid.Keypress

3

Re: Keypress problem

Hi Hans,
1) When you need Keypress inside a grid, better set form's keypreview to .T. and code in form's Keypress method.
2) Since you are actually trying to do something on row change, as Soykan said do it in AfterRowColChange ( up, down are not the only keys that would change the row ). ie:

*afterrowcolchange

Visual Fox Pro
lparameters nColIndex

if ( this.RowColChange % 2 = 1 ) && It is a row change
    THISFORM.txtTransfdate.Refresh
endif

4

Re: Keypress problem

Thank you, guys. I will try what you suggested. Sure it will work.

I will do the same for Page Up and Page Down (I left them out to simplify my problem). Ctrl-Home and Ctrl-End are also involved, of course.

Regards,

Hans L

5

Re: Keypress problem

Cetin, why the roundabout with the % operator. Wouldn't

Visual Fox Pro
if this.RowColChange = 1

work as well?

Value  Description 
0  (default)  No change.
1  Row change
2  Column change
3  Row and column change

And, 1 % 2 = 0, not 1

Regards,

Hans L

6

Re: Keypress problem

1 % 2 = 1 && It is a row change
3 % 2 = 1 && It is both a row and col change - we want to catch this one either