Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving through a grid 1

Status
Not open for further replies.

mpgalvin

Programmer
Feb 5, 2001
119
IE
I've got a grid (yes, the same grid as my previous problem, bl00dy grids, mumble, whine) which is bound to a table. There is only one column on the grid available to the user, so I've set it so that if any of the other columns get focus, focus is set back to the available column.

Anyway, my problem is that I want to allow the user to use the <RET> key to move through the records -- when they press return, it moves down the grid, as if the down cursor was used. I tried putting this into the KeyPress event:

Code:
IF nKeyCode = 13
    SKIP
ENDIF

but it doesn't appear to do anything, or it certainly doesn't move to the next record. I was sure I could do something like this, although I'm not convinced KeyPress is the right event.

Any thoughts, all y'all?
 
You can also disable the other columns. Set the property Enabled = .F.

HTH,
Weedz (Wietze Veld)
veld4663@exact.nl
The Netherlands

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Code in the 'KeyPress Event' of the form...
===========================================
LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 13
ThisForm.Nav_search1.cmdNext.Click()
ENDIF
IF nKeyCode = 5 .AND. !BOF()
ThisForm.Nav_search1.cmdPrevious.Click()
NODEFAULT
ENDIF
IF nKeyCode = 24 .AND. !EOF()
ThisForm.Nav_search1.cmdNext.Click()
NODEFAULT
ENDIF
IF nKeyCode = 18 .AND. !BOF()
SKIP - WROWS()
ThisForm.Nav_search1.cmdPrevious.Click()
NODEFAULT
ENDIF
IF nKeyCode = 3 .AND. !EOF()
SKIP WROWS()
ThisForm.Nav_search1.cmdNext.Click()
NODEFAULT
ENDIF
=====================================
I have copied from my search form and so the refernces of ThisForm.Nav_Search1. etc exists. You can substitute it to refer your navigation class suitably.

Remeber to set the KEYPREVIEW property to .T. in the form.
Also remember to set focus to the grid suitably after the keypress event execution.

The above will show you the idea to intercept the key presses thru the forms keypress event and do what you need.


ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
fluteplr - the KeyPress event of the grid.column.text control.

Ramani, thanks for the code, but I don't have a navigation class. Any chance of getting yours :)? Or at the least the code behind Cmd_Next, since I think that's the one I want.
 
Further to your question

IF ! EOF()
SKIP
ENDIF
IF EOF()
LOCATE && or GO BOTTOM
ENDIF
ThisForm.Refresh()
ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
To shorten the whole thing ....
=======================================
Code in the 'KeyPress Event' of the form...
===========================================
LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 13
IF ! EOF()
SKIP
ENDIF
IF EOF()
LOCATE && or GO BOTTOM
ENDIF
NODEFAULT
ThisForm.Refresh()
ENDIF

Note to set focus to the gid depending on your situation. ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Ramani, thanks. I forgot to refresh after moving. God, it's pretty crappy, isn't it - a lot of flicker! :)

Anyway, that's what the boss wants...
 
You can avoid the flicker if the screen gets locked and then refreshed. This will appear much faster to your users as well. To do it create your own MyFormRefresh method in your baseform. In all places call ThisForm.MyRefreshForm() instead of refreshform event.
************************************************************
** since the screen is locked and then refreshed.
************************************************************
** MyFormRefreshForm()
LOCAL llResetLockScreen

llResetLockScreen = (This.LockScreen = .f.)
This.LockScreen = .t.

This.Refresh()

IF llResetLockScreen
This.LockScreen = .F.
ENDIF
************************************************************
ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
mpgalvin

I may be misreading the question, but it appears you want to use the Enter key to move laterally through the fields of a single record?

If so:-

ON KEY LABEL ENTER KEYBOARD [{TAB}]

in say the .Init event of the grid and

ON KEY LABEL ENTER

as the grid loses focus.

Alternatively you can change the Enter key's behaviour in any cell, with the same code.

Chris :)



 
Chris, you were misreading the question :)-)) I want the <RET> key to act the same as the down-arrow.
 
mpgalvin

In that case try:-

ON KEY LABEL ENTER KEYBOARD [{DNARROW}]

In testing here the record pointer is moving to the next record in the grid

Chris :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top