System.Windows.Forms.TreeNodeCollection.IndexOfKey Method

Returns the index of the first occurrence of a tree node with the specified key.

Syntax

public virtual int IndexOfKey (string key)

Parameters

key
The name of the tree node to search for.

Returns

The zero-based index of the first occurrence of a tree node with the specified key, if found; otherwise, -1.

Remarks

If TreeNodeCollection.IndexOfKey(string) is called successively, the last returned index will be checked for a key match first, and if there is no match, the search starts at the beginning of the collection.

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

The key comparison is not case-sensitive. If key is null or an empty string, the TreeNodeCollection.Item(string) property returns -1.

Requirements

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