Language Reference Guide : System Classes : Tree Class : AddNode Method
 
Share this page          
AddNode Method
The AddNode method adds a new node to the tree. The new node object is returned.
This method has the following syntax:
TreeNode = Tree.AddNode(name = nvarchar(256)
          [, keylabel = varchar(256), relative = TreeNode, relation = integer])
This method has the following parameters:
name
(Required) Specifies the label string
keylabel
Specifies a unique string associated with the node that is used to retrieve a node with the NodeByKey method
relative
Specifies an existing TreeNode in the Tree
relation
Specifies the relationship of the node to the TreeNode specified in the relative parameter. Valid values are:
TN_LASTCHILD
Specifies that the new node is the last child of relative
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
TN_CHILDBYLABEL_ASC
Specifies that the new node is to be a child of the relative and is to be inserted among the children, sorted by label in ASCII ascending order. The new node will be put in the first slot that makes sense in this ordering and will not check whether subsequent siblings are in correct order. If all children of a node are inserted using TN_CHILDBYLABEL_ASC order, this will guarantee that all the children will be correctly sorted.
TN_CHILDBYLABEL_DESC
Similar to TN_CHILDBYLABEL_ASC, except inserts in ASCII descending order
TN_CHILDBYKEY_ASC
Similar to TN_CHILDBYLABEL_ASC, except sorts by Key and not by TextLabel
TN_CHILDBYKEY_DESC
Similar to TN_CHILDBYKEY_ASC, except inserts in ASCII descending order
Default: TN_LASTCHILD
Descriptions of system constant values and their numeric equivalents are listed in Relative Parameter Values for TreeNodes.
If relative is NULL, the relation parameter is ignored, and the new node becomes the root. The old root, if exists, becomes the next sibling of the new root.