Nodes Collection Method: Add 

Purpose

Adds a new Node object to the Nodes collection.

Syntax

The Add method has the syntax:

Object Add(Variant vaRelative, CTreeAddType Relationship, String Key, Variant Text, Long Image, Long SelectedImage)

Parameters

Indicates either an already existing node object or Nothing or an empty variant. A node may be referenced by an object expression containing the node or a string expression containing the key for the desired node.

The relationship between the new node and vaRelative is described in the parameter Relationship. The combination of vaRelative and Relationship defines the position of the new node to be inserted. If vaRelative is empty or Nothing, the new node is inserted as a root node. Relationship may not be equal to TreeAddFirstChild or, in this case, TreeAddLastChild.

Describes the relationship between vaRelative and the new node. Possible value are:

A unique Key value used to identify the Node object. This value may later be used to retrieve the node through the Nodes collection’s Item property. A valid value for Key is also an empty string. This prevents the key from being inserted into the key map.

Describes initialization data for the new node to be inserted. There are two valid variant data types for this parameter:

The first Item of type text is initialized with Text. (See also Structure Object).

The object pointed to by Text must be a Node object. All items with the same name and data type in both nodes (that is, in the Text node and the newly created node) are copied from Text to the new node. The item need not be a node from the same control, but it must be a node from the same application.

Indicates the image to be used for the first image typed item. If Image equals -1, pre-defined images for folders and leafs are used. Otherwise, Image is an index in the ImageList property of the Table Tree object. (See also the properties for The Table Tree Control.)

(Not yet supported.)

Return Value

type Object

Description

This method adds a new Node object to the Nodes collection.

Note that adding a new node does not necessarily mean the node becomes visible. If any sibling of the node is visible, the new node will also be visible if possible. (See also the node’s Type property and the root’s Type property). If you want the node to be visible, call EnsureVisible on the new node object.

The node’s Type property is initialized with trvNodeTypeFolder. If you want a node of type trvNodeTypeLeaf inserted, call AddEx or modify the Type property of the new node object.