Skip to content

InsertTreeItem - AbstractTreeView

Inserts an item in a TreeView

Type: Function
Return Data Type: Handle

Parameters

Parameter Type Description
sValue String The text you want displayed for the item
hParent Handle The handle of the item that you want as the parent of this item (pass 0 to create an item with no parent - a root item)
hInsertAfter Handle The handle of the item to immediately insert the new item after
iItemData Integer A user-defined 32-bit integer you want to associate with the item
iImage Integer The index of an image in the associated ImageList (which you need to create separately) that will be displayed alongside the item whenever it is not the current-item
iSelImage Integer The index of an image in the associated ImageList that will be displayed alongside the item whenever it is the current item

Syntax

Function InsertTreeItem String sValue Handle hParent Handle hInsertAfter Integer iItemData Integer iImage Integer iSelImage Returns Handle

Call Example

Get InsertTreeItem sValue hParent hInsertAfter iItemData iImage iSelImage to HandleVariable

Description

Used to insert an item in a TreeView.

Sample

This example creates a root node and adds 2 children to it. It then inserts a new child node between the first 2 child nodes added.

Procedure MyCustomMethod
    Handle hRoot hCake hSteak hGrapes

    // add root node
    Get AddTreeItem "Food" 0 0 0 0 to hRoot
    // add 2 child nodes of root node
    Get AddTreeItem "Cake"  hRoot 0 0 0 to hCake
    Get AddTreeItem "Steak" hRoot 0 0 0 to hSteak

    // insert grapes child node of root node after cake node
    Get InsertTreeItem "Grapes" hRoot hCake 0 0 0 to hGrapes
End_Procedure

To insert a new item as the first child of a parent item, pass TVI_FIRST as the hInsertAfter parameter.

For example:

Get InsertTreeItem "Apples" hRoot TVI_FIRST 0 0 0 to hApples

Return Value

The handle of the inserted item