10147 : How can I make a tree node selected in phGantX?

Question

How can I make a tree node selected, I use ‘Selected = True’ but it’s not doing anything.

Example here:

Private Sub phGantX_OnDblClickGantArea(ByVal theGant As phGantXControl.IphGantX, ByVal theDataEntity As phGantXControl.IphDataEntity_GantTime)
  Dim phActivity As IphDataEntity_Tree2
  ‘open / close tree nodes
  If Not (theDataEntity Is Nothing) Then
    Set phActivity = theDataEntity.Row.TreeNode
    phActivity.Expanded = True
    phActivity.Selected = True ‘<–No tree row highlight ?
  End If
End Sub

Answer

The Selected property works if you use the tree (not recommended, deprecated), but you use the grid (good choice), and then the selection is per cell rather than per row.

To select an individual cell you call IphGantX3.SetGridCellSelected(x,y,true/false). But the grid handles multi-select, so there is a difference between select and focus.
You probably want to set the focused cell, and you do this with the properties IphGantX3.GridCellFocusedX and IphGantX3.GridCellFocusedY.

So in the case above you would go:

Private Sub phGantX_OnDblClickGantArea(ByVal theGant As phGantXControl.IphGantX, ByVal theDataEntity As phGantXControl.IphDataEntity_GantTime)
  Dim phActivity As IphDataEntity_Tree2
  ‘open / close tree nodes
  If Not (theDataEntity Is Nothing) Then
    Set phActivity = theDataEntity.Row.TreeNode
    phActivity.Expanded = True

    theGant.GridCellFocusedX=0
    theGant.GridCellFocusedY=theDataEntity.Row.TreeNode.GridRowIndex

  End If
End Sub

Leave a Reply