10505 : newactivity.GridRowIndex is -1


I’m using the COM component and need help working with row heights and labels on a time object.  I’m using TimeItemsTextSetEx to display the text above the time item, but I’m having trouble determining how to resize the row height.  Here’s the code I’m using based on the GanttTest sample that installed with phGantt:

Private Sub LoadTreeItemsOwnedBy(activity As IphDataEntity_Tree2, ownerid As Integer) Dim newactivity As IphDataEntity_Tree2 Dim aRS As Recordset Dim selectstat As String Dim y As Long
    selectstat = “select id,name,owningactivity from activity where owningactivity=”
    selectstat = selectstat + Str(ownerid)
    Set aRS = New Recordset
    aRS.Open selectstat, db, adOpenStatic, adLockReadOnly
    While Not aRS.EOF
        If activity Is Nothing Then
            Set newactivity = phGantX1.AddRootDataEntityTree
            Set newactivity = phGantX1.AddDataEntityTree(activity)
        End If

        y = newactivity.GridRowIndex
        InitActivity newactivity, aRS
        LoadTreeItemsOwnedBy newactivity, newactivity.UserIntegerReference
        If y >= 0 Then
            phGantX1.SetRowHeightGrid y, phGantX1.GetRowHeightGrid(y)
        End If
End Sub

The problem is that y always evaluates to -1.  How do I resize the rows?  Thanks.


Not entirily sure why the y = newactivity.GridRowIndex is -1 in this case. Could be a couple of things… First; ary using the grid Gantt.UseGrid=true? If not the old tree is used and then no grid nodes will exist -> Set Gantt.UseGrid=true.
Second; It could be that you are in this load loop and that the Grid items get no chance to update them self. To verify if this is the case, loop thru the nodes in a button implementation and get GridRowIndex, if it is ok then its an update problem… Send us a sample, so we may debug and find out how to fix it.

Anyway, you can also control GridRowHeights by the defining a IphGridLayoutPropX, set its MinHeight property and assign it to at least one cell in the row (IphGantX3.SetGridCellLayoutPropIndex), and your row will get that row height (only works for UseGrid=true)

Leave a Reply