7. Working with List Views and Tree Views : TreeNode and Tree Classes : Tree Class : AddNode Method
 
Share this page                  
AddNode Method
The AddNode method creates a node and adds it to the tree. It is the basic method for building a tree.
This method has the following syntax:
treenode = tree.AddNode
(
     name         = varchar(256),
     [keylabel     = varchar(256),]
     [relative     = treenode,]
     [relation     = integer]
);
The AddNode method has one mandatory parameter, and three optional parameters:
name
(Required) Specifies the node's TextLabel attribute
keylabel
(Optional) Lets you specify a unique string that is associated with the new node. If you specify a key label, you may use the NodeByKey method to search for the node.
relative
(Optional) Specifies an existing node in the tree. If relative is not specified or is null, the new node becomes the root node of the tree; the old root node, if it exists, becomes a sibling of the new root node.
relation
(Optional) Specifies the relation of the new node to relative. The possible values of relation are:
TN_LASTCHILD
Specifies that the new node is the last child of relative. This is the default if relation is not specified.
TN_FIRSTCHILD
Specifies that the new node is the first child of relative
TN_NEXTSIBLING
Specifies that the new node is the next sibling of relative
The AddNode method returns the newly created node.