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, string imageKey, string selectedImageKey)

Parameters

key
The name of the tree node.
text
The text to display in the tree node.
imageKey
The key of the image to display in the tree node.
selectedImageKey
The key of the image to display when the node is in a selected state.

Returns

The System.Windows.Forms.TreeNode 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 imageKey parameter refers to an image in the TreeView.ImageList property of the parent System.Windows.Forms.TreeView.

The selectedImageKey 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