System.Windows.Forms.TreeNodeCollection.Insert Method

Creates a tree node with the specified key, text, and images, and inserts it into the collection at the specified index.

Syntax

public virtual TreeNode Insert (int index, string key, string text, string imageKey, string selectedImageKey)

Parameters

index
The location within the collection to insert the node.
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 in the tree node when it is in a selected state.

Returns

The System.Windows.Forms.TreeNode that was inserted in the collection.

Remarks

If the TreeView.Sorted property is set to true, the index parameter value is ignored. The System.Windows.Forms.TreeNode is inserted into the tree view and the System.Windows.Forms.TreeView is sorted again.

You can also add new System.Windows.Forms.TreeNode objects to the collection by using the erload:System.Windows.Forms.TreeNodeCollection.Add or TreeNodeCollection.AddRange(TreeNode[]) methods.

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

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