method Items.InsertItem ([Parent as HITEM], [UserData as Variant], [Caption as Variant])

Inserts a new item, and returns a handle to the newly created item.

TypeDescription
Parent as HITEM A long expression that indicates the item's handle that indicates the parent item where the newly item is inserted.
UserData as Variant A Variant expression that indicates the item's extra data.
Caption as Variant A string expression that indicates the cell's caption on the first column, a safe array that holds the caption for each column.
ReturnDescription
HITEMRetrieves the handle of the newly created item.

The InsertItem property fires the AddItem event. Use the InsertItem property to add a new child to an item. You can use the InsertItem(,,"Root") or AddItem("Root") to add a root item. An item that has no parent is a root item. To insert an ActiveX control, use the InsertControlItem property of the Items property. Use the CellCaptionFormat property to specify whether the cell displays the caption using the HTML format. Use the CelllCaption property to assign captions for cells in a multi-column group. Use the LockedItemCount property to lock or unlock items to the top or bottom side of the group. Use the MergeCells method to combine two or more cells in a single cell. Use the SplitCell property to split a cell.

The following sample shows how to create a simple hierarchy into your group:

With ExplorerTree1.Groups.Add("Simple Tree")
    
    .AutoHeight = True
    .ColumnAutoResize = True
    .LinesAtRoot = True
    .FullRowSelect = False
    .MarkSearchColumn = False
    
    .BeginUpdate
        ' By default the group adds a default column
        With .Items
            Dim h As HITEM
            h = .InsertItem(, , "Root")
            .InsertItem h, , "Child1"
            h = .InsertItem(h, , "Child2")
            .InsertItem h, , "SubChild21"
            h = .InsertItem(h, , "SubChild22")
        End With
    .EndUpdate
    
End With

The following VB sample adds items when control has multiple columns:

With ExplorerTree1.Groups.Add("Simple Tree")
    
    .AutoHeight = True
    .ColumnAutoResize = False
    .LinesAtRoot = exLinesAtRoot
    .HeaderVisible = True
    
    .BeginUpdate
    
        ' By default the group adds a default column, so we only change it's caption
        With .Columns(0)
            .Caption = "Column 1"
            .Width = 64
        End With
        .Columns.Add "Column 2"
        .Columns.Add "Column 3"
        
        Dim h As HITEM
        With .Items
            h = .AddItem(Array("Item 1.1", "Item 1.2", "Item 1.3"))
            .InsertItem h, , Array("Item 2.1", "Item 2.2", "Item 2.3")
        End With
        
    .EndUpdate
End With

With ExplorerTree1.Groups.Add("Empty Group")
End With