Add (Nodes)

This method adds a Node object to the Nodes collection of a TreeView control.

Syntax

nodes.Add([relative], [relationship], [key], text, [image], [selectedimage])

Parameters

nodes
Required. The name of a Nodes collection.
relative
Optional. The index number or key of a pre-existing Node object. The relationship between the new node and this pre-existing node is found in the relationship parameter.
relationship
Optional. Specifies the placement of the Node object in relation to relative.
key
Optional. Unique string expression that can be used to access a member of the Nodes collection.
text
String associated with the TreeView control.
image
Optional. Integer that sets the icon to be displayed from the ImageList control associated with the TreeView control.
selectedimage
Optional. Integer that sets the icon to be displayed from an ImageList control when the Node is selected.

Return Value

Reference to the new Node object.

Remarks

The following table shows the possible values for the relationship parameter.

Constant
Value
Description
tvwFirst 0 First. Node is placed before all other nodes at the same level of the node named in relative.
TvwLast 1 Last. Node is placed after all other nodes at the same level of the node named in relative. Any Node added subsequently may be placed after the one added as Last.
TvwNext 2 (Default) Next. Node is placed after the node named in relative.
TvwPrevious 3 Previous. Node is placed before the node named in relative.
TvwChild 4 Child. Node becomes a child node of the node named in relative.

If no Node object is named in relative, the new node is placed in the last position of the top node hierarchy.