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

Setting Focus to a Grid 3

Status
Not open for further replies.

vj

Programmer
Nov 18, 2000
58
MU
Hi guys,

I have a textbox and a grid right below the textbox .. now as the user types into the textbox ... the matching result set is displayed in the grid below... This is all working fine ... now i want the cursor to be inside the grid just as soon as the user presses the down-arrow key in the text box .

i'v put this code into the keypress event of the textbox :

IF NKEYCODE=24
THIS.Parent.Grd_List2.SetFocus
ENDIF

it does work .. becoz i get the value from the first row inside the grid .. but the cursor does not stay inside the grid .. instead jumps to another textbox. any idea how to keep the cursor inside the grid.

thankx guys.
Vijay Singh Rawat

 
Is your grid allowing to get focus?
Have you tried setting focus more directly and explicit to a certain grid column control?

What could prevent it: Enabeld =.f., readonly cursor, the WHEN event of the grid or it's first control getting focus returns .F., AllowCellSelection=.F.

Bye, Olaf.
 
hi olaf,

i'v checked all of it ... still the same ... can't seem to understand .. why the cursor jumps onto another textbox ! the cursor should just stay there inside the grid .. right ?
 
Maybe a NODEFAULT ?
Code:
IF NKEYCODE=24
	NODEFAULT 
	THIS.Parent.Grd_List2.SetFocus 
ENDIF


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Vilhelm-Ion said:
Maybe a NODEFAULT ?

Yes, I'll bet that's right. What's happening is that you correctly set the focus to the grid, but the down-arrow key is still in the keyboard buffer, so VFP processes that key, which causes focus to move to the next control. The NODEFUALT will fix that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>i'v checked all of it
Is it clear all of the conditions I mentioned will make the grid refuse to get focus?

>the cursor should just stay there inside the grid .. right ?

As you don't have NODEFAULT, what Vilhelm-Ion Praisach said is true. I'd expect to stay in the grid, if you aren't positioned on the last record or EOF, you'll just end up one record below. If you indeed are positioned on the last record or EOF and set focus to the grid, you end up in the control with next tab order after the grid.

Bye, Olaf.
 
hi guys ...

ok .. the default did the trick ...

IF NKEYCODE=24
NODEFAULT
THIS.Parent.Grd_List2.SetFocus
ENDIF

ok .. it's working just perfect now .

thankx vgulielmus and everyone else.
vijay singh rawat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top