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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how CTRL+UPARROW to copy above cell in a GRID ? 2

Status
Not open for further replies.

johan3000

MIS
Dec 17, 2010
18
ID
Hi ALL,

in inkey() :

Key Alone SHIFT CTRL ALT
UP ARROW 5 56 141 152
DOWN ARROW 24 50 145 160

where and how I can trap the CTRL+UPARROW n CTR:+DNARROW
to do the job? (is it using INKEY or what?)


this is what I have in VALID clause in a GRID.info.text
IF InString(cVal,"-=Cc") && can be either on of char
SKIP -1 IN GL
cinfo = GL.info
SKIP 1 IN GL
this.Value = RTRIM(cinfo)
* entering edit mode (like F2 in Excell)
KEYBOARD '{BACKTAB}{END}'
RETURN .t.
ENDIF

However, giving the user CTRL+UPARROW will work better!
CTRL+DNARROW to copy cell below..

please help!
 
Johann,

Don't use INKEY() for this. Better to use the KeyPress event of the control (usually a textbox) within the grid column.

Within the KeyPress event, the value of nKeyCode will be 141 and 145, for Ctrl+UpArrow and Ctrl+DownArrow respectively.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike told you how to get there, but I'd caution you not to. :)

CTRL-UPARROW and CTRL-DNARROW have been such well-known navigation keystrokes for so many years it's probably not a good idea to use them to mean something different. It would be like redefining PGUP and PGDN.
 
thanks MikeLewes n danFreeman, your answers are very helpful.

Here is my code (tested) in the in the grid
object:text1, procedure:keypress


LPARAMETERS nKeyCode, nShiftAltCtrl
LOCAL cInfo, nRecNo

* This part allow the user to copy above/below cell
* using ctrlUp or ctrlDn
*
* nShiftAltCtrl Modifier key
* 1 SHIFT
* 2 CTRL
* 4 ALT
* ctrlDnArrow = 145 2
* ctrlUpArrow = 141 2

IF nShiftAltCtrl = 2 && ctrl
IF nKeyCode = 145 .or. nKeyCode = 141 && up/dn
nRecNo = RECNO()
IF nKeyCode = 141 then
SKIP -1 IN ks_jnl
KEYBOARD '{DNARROW}'
ENDIF
IF nkeyCode = 145 then
SKIP 1 IN ks_jnl
KEYBOARD '{UPARROW}'
ENDIF
IF EOF()
GOTO nRecNo
ENDIF
cInfo = gl.info
GOTO nRecNo
this.Value = RTRIM(cInfo)
* entering edit mode (like F2 in Excell)
RETURN .t.
ENDIF
ENDIF

danFreeman, it is the user wanted that control key... cause after going up and down... it is the easiest to copy the content by giving the ctrl+up or ctrl+dn to do the jobs.

otherwise, I agree with you solution.

if there is any better solution, please let me know!
have a nive day.
 
Johan,

Do your users use Excel? If so, why not suggest they use CTRL + Double-Quote (keycode = 34) to copy the cell above? That would mimic the behaviour of Excel, and is easy to remember because a double-quote looks like a ditto mark.

To copy the cell below, you could perhaps suggest CTRL + SHIFT + Double-Quote.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top