10018 : How to get the TreeNode from a TimeItem

Question

In our program the user selects a time item.  When I then wants to edit a item another window will be show with all the details of the item. He users makes some changes and the data will be stored. The ghant will then reload automaticly. Pretty straightforward so far. < ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I would like to automaticly return to the row on which the time item is that was edited. I know I can go to a certain row using : 

Dim aTreeItem As phGantXControl.IphDataEntity_Tree2

Give aTreeItem a destination and then use : 

phGantX1.SetTopItemTree aTreeItem

I already use this in our search function. In my click function I have got (for some other thing in the program) :

 Private Sub phGantX1_OnClickGantArea(ByVal theGant As phGantXControl.IphGantX, ByVal theDataEntity As phGantXControl.IphDataEntity_GantTime)

    On Error Resume Next

    If (Not phGantX1.ActiveDataEntity Is Nothing) Then

        PlanningId = theDataEntity.UserIntegerReference

    End If

End Sub

 

But how can I now set the variable aTreeItem to the correct row/treenode?

 

Resolution

If you have a time item and need its owning tree node you can do like this:

theTimeItem As phGantXControl.IphDataEntity_GantTime2

theTimeItem=theDataEntity ‘ Make sure we use the IphDataEntity_GantTime2 interface

theRow as IphGantRow3

theRow=theTimeItem.Row

theRow.TreeNode ‘ we have the treenode

The pitfall of this exercise is the fact that you sometimes need to cast to a newer interface (same name but a higher number postfix) that holds more information; the IphDataEntity.Row returns a IphGantRow, but we need a IphGantRow3 that has the row property. In VB we cast by assigning to a variable of the desired type. In c# we would use the “As” operator