property Items.ItemPosition(Item as HITEM) as Long
Retrieves or sets a value that indicates the item's position in the children list.

 TypeDescription 
   Item as HITEM A long expression that indicates the item's handle.  
   Long A long expression that indicates the item's position in the children list.  

The ItemPosition property gets the item's position in the children items list. You can use the ItemPosition property to change the item's position after it been added to collection. When the control sorts the tree, the item for each position can be changed, so you can use the item's handle or item's index to identify an item. Use the SortChildren method to sort the child items. Use the SortOrder property to sort a column. The FormatColumn event is fired before displaying a cell, so you can handle the FormatColumn to display anything on the cell at runtime. This way you can display the row position, you can display the value using the currency format, and so on. The FireFormatColumn property allows the control to fire the FormatColumn event for the column. The Position property specifies the position of the column.

The following VB sample handles the FormatColumn event to display the row position:

Private Sub G2antt1_FormatColumn(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, Value As Variant)
    Value = G2antt1.Items.ItemPosition(Item)
End Sub 
Private Sub G2antt1_FormatColumn(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, Value As Variant)
    Value = G2antt1.ScrollPos(True) + RelPos(Item)
End Sub

Private Function RelPos(ByVal hVisible As Long) As Long
    With G2antt1.Items
        Dim h As Long, i As Long, n As Long
        i = 0
        n = .VisibleCount + 1
        h = .FirstVisibleItem
        While (i <= n) And h <> 0 And h <> hVisible
            i = i + 1
            h = .NextVisibleItem(h)
        Wend
        RelPos = i
    End With
End Function

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.