CLEAR _Screen.AddObject("other", "textbox") _Screen.other.Visible = .T. * prepare some data CREATE CURSOR Source (Col Varchar(200)) INSERT INTO Source VALUES ("Some Text") INSERT INTO Source VALUES ("Some more Text") INSERT INTO Source VALUES ("") GO TOP LOCAL Test AS FRM * instantiate a modeless form with a grid inside m.Test = CREATEOBJECT("FRM") m.Test.Show() READ EVENTS m.Test = .NULL. _Screen.RemoveObject("other") DEFINE CLASS FRM AS Form Top = 60 Left = 120 ADD OBJECT GRD AS Grid WITH ColumnCount = 1 * closing the form will terminate the test PROCEDURE Destroy CLEAR EVENTS ENDPROC PROCEDURE GRD.Init This.RowHeight = 40 This.RecordSource = "Source" WITH This.Columns(1) AS Column .AddObject("Editor", "EditBoxSP") .Editor.Visible = .T. .CurrentControl = "Editor" .RemoveObject("Text1") .Sparse = .F. ENDWITH ENDPROC * Grids don't have a LostFocus. Valid (which in fact should stand for BeforeLostFocus) is close enough, though. * We use it to signal that the user has quit editing the grid and he/she is going somewhere else. * When user remains inside the grid, the behavior is standard. * The reference to the control is hard-coded. In real life? It won't be, of course. PROCEDURE GRD.Valid IF This.ActiveColumn != 0 AND UPPER(This.Columns(This.ActiveColumn).CurrentControl) == "EDITOR" This.Columns(This.ActiveColumn).Editor.OutOfGridPosition = This.Columns(This.ActiveColumn).Editor.SelStart ENDIF ENDPROC ENDDEFINE DEFINE CLASS EditBoxSP AS EditBox OutOfGridPosition = -1 PROCEDURE GotFocus * repositioning with the Keyboard is only done when the user is coming back to the grid, after his/her errands IF This.OutOfGridPosition != -1 * from the start, as much as needed KEYBOARD '{HOME}'+REPLICATE('{RIGHTARROW}', This.OutOfGridPosition) This.OutOfGridPosition = -1 ENDIF ENDPROC ENDDEFINE