10303 : Setting focus on the grid in phGantX

Question

I cannot get an item to be selected and highlighted using code.  When I add a new item using code I would like to have it selected so that the user can begin typing immediately to edit the text without having to select the item with the mouse. I have tried the following items:

    TreeEntity.Expanded = True
    NewProject.Expanded = True
    phGantX1.SetCurrentDataEntityTree NewProject
    phGantX1.SetGridCellSelected 0, NewProject.GridRowIndex, True
    phGantX1.GridCellFocusedX = 0
    phGantX1.GridCellFocusedY = NewProject.GridRowIndex

The best I can do is get the row to be grey but not selected with a focus rectangle ready to type.

Answer

 What is lacking seems to be the focus of the control. You can call the win32 function SetFocus to set focus to a specific windows handle. You can get the windows handle to the grid with IphGantX3.HWndGrid.

Leave a Reply