System.Windows.Forms.TreeNodeCollection.Insert Method

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

Syntax

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

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.
imageIndex
The index of the image to display in the tree node.

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 imageIndex parameter refers to an image in the TreeView.ImageList 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