System.Windows.Forms.TreeNodeCollection.Add Method

Creates a tree node with the specified key, text, and images, and adds it to the collection.

Syntax

public virtual TreeNode Add (string key, string text, int imageIndex, int selectedImageIndex)

Parameters

key
The name of the tree node.
text
The text to display in the tree node.
imageIndex
The index of the image to display in the tree node.
selectedImageIndex
The index of the image to be displayed in the tree node when it is in a selected state.

Returns

The tree node that was added to the collection.

Remarks

The TreeNode.Name property corresponds to the key for a System.Windows.Forms.TreeNode in the System.Windows.Forms.TreeNodeCollection.

The tree node is added to the end of the collection. You can also add new System.Windows.Forms.TreeNode objects to the collection by using the TreeNodeCollection.AddRange(TreeNode[]) or erload:System.Windows.Forms.TreeNodeCollection.Insert methods.

The imageIndex parameter refers to an image in the TreeView.ImageList property of the parent System.Windows.Forms.TreeView.

The selectedImageIndex parameter refers to an image in the TreeView.StateImageList property of the parent System.Windows.Forms.TreeView.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0