I have a small program which allows me to add/delete a row in a grid.
When I add an ITEM I want the focus to be set a the second cell from the last insert row + set to be in EDIT, in order to fill in the new value.
What happens now is that a row is inserted but one has to double click to get insert the new value.
So I need two things:
1 setfocus to the inserted row at column 2
2 force to EDIT mode.
This is the code I use. If someone would be so kind to help...
Code: Select all
#include "hmg.ch"
FUNCTION MAIN()
/*************/
aENUM2 := {}
FOR A = 1 TO 10
AADD(aENUM2, {.F., ALLTRIM(STR(A))} ) // some data
NEXT
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 290 ;
HEIGHT 720 ;
TITLE ' Values ' ;
ICON "DEFAULT" ;
MAIN
ON KEY ESCAPE ACTION { Form_1.Release }
DEFINE GRID Grid_1
ROW 10
COL 10
WIDTH 270
HEIGHT 600
HEADERS {'DEL', 'Values'}
WIDTHS {40, 210}
JUSTIFY {GRID_JTFY_LEFT, GRID_JTFY_LEFT}
COLUMNWHEN { {|| .T. }, { || .T. } }
COLUMNCONTROLS { { 'CHECKBOX', 'Yes' , 'No' }, ;
{ 'TEXTBOX', 'CHARACTER'}}
ALLOWEDIT .T.
ITEMS aENUM2
END GRID
DEFINE BUTTON Start_ADD
ROW 620
COL 10
WIDTH 50
HEIGHT 70
ACTION NEW_VALUES()
CAPTION "Add"
TRANSPARENT .T.
TOOLTIP "Add a line"
PICTURE "HMG_EDIT_NEW"
PICTALIGNMENT TOP
END BUTTON
END WINDOW
ACTIVATE WINDOW Form_1
RETURN
FUNCTION NEW_VALUES()
/***************************/
Form_1.Grid_1.AddItem({.F.,''})
nLAST := Form_1.Grid_1.Itemcount
//cCell := Form_1.Grid_1.CellEx( nLAST, 2 )
DoMethod( 'Form_1' , 'Grid_1' , 'SetFocus', Form_1.Grid_1.CellEx( nLAST, 2 ) ) // this doen't work
RETURN