I am using vfp 8.

In the form's init method I have:

thisform.keypreview = .t.

In the form's keypress method I have:

LPARAMETERS nKeyCode, nShiftAltCtrl
DO case
CASE nkeycode = 14 AND nShiftAltCtrl = 2 && ctrl+n
thisform.cmdNew.Click
nodefault
...

and in cmdNew's click method:,

Append Blank
Goto Bottom
Thisform.grd1.COLUMN1.SetFocus

When I press ctrl+n in the first column in the grid everything works fine. A
new row is added in the grid and the first column of it is selected.

When I press ctrl+n in the second column, a new row is added as it should,
but it is the first column in the CURRENT row that gets the focus.

If I press the New button from the second column everything works as it
should.

What am I doing wrong?

Sincerely,

Jan Nordgreen

Keypress problem with ctrl+n by Brian

Brian
Tue Dec 02 18:09:38 CST 2003

I usually find in these cases that moving focus off the
grid, then back to it solves the problem
eg THISFORM.cmdNew.SetFocus()
THISFORM.grdWhatever.SetFocus()
Focus never moves from the grid because the action was
initiated by keypress as opposed to clicking on the New
button.
Another option would be to programatically set focus to
the new button in your keypress event before calling Click
()

.. I thought these issues had been largely fixed in VFP8
grids but perhaps not all...
Hope this helps...
Brian

>-----Original Message-----
>I am using vfp 8.
>
>In the form's init method I have:
>
>thisform.keypreview = .t.
>
>In the form's keypress method I have:
>
>LPARAMETERS nKeyCode, nShiftAltCtrl
>DO case
>CASE nkeycode = 14 AND nShiftAltCtrl = 2 && ctrl+n
> thisform.cmdNew.Click
> nodefault
>....
>
>and in cmdNew's click method:,
>
>Append Blank
>Goto Bottom
>Thisform.grd1.COLUMN1.SetFocus
>
>When I press ctrl+n in the first column in the grid
everything works fine. A
>new row is added in the grid and the first column of it
is selected.
>
>When I press ctrl+n in the second column, a new row is
added as it should,
>but it is the first column in the CURRENT row that gets
the focus.
>
>If I press the New button from the second column
everything works as it
>should.
>
>What am I doing wrong?
>
>Sincerely,
>
>Jan Nordgreen
>
>
>
>.
>

Re: Keypress problem with ctrl+n by Jan

Jan
Wed Dec 03 06:30:36 CST 2003

Brian,

I tried the second option ('Another option would be to programatically set
focus to
the new button in your keypress event before calling Click') and it worked
perfectly!

Thank you for answering!!! I was afraid no one would as the days went by and
I observed all questions were answered, except mine. :)

Take care!

Jan Nordgreen



Re: Keypress problem with ctrl+n by Willianto

Willianto
Wed Dec 03 14:49:20 CST 2003

Hi Jan,

> ... I was afraid no one would as the days went
> by and I observed all questions were answered, except mine. :)

I always take that as 'Hmmm... my skill is improving' ;-) Although that
*still* doesn't solve the problem <lol>

Just my 2c
Willianto



Re: Keypress problem with ctrl+n by Jan

Jan
Wed Dec 03 20:53:29 CST 2003

Hi Willanto,

I like your interpretation. :)

"Life is not what happens to you, it is how you interpret it."

Jan