System.Windows.Forms.TreeNodeCollection.Contains Method

Determines whether the specified tree node is a member of the collection.

Syntax

public bool Contains (TreeNode node)

Parameters

node
The System.Windows.Forms.TreeNode to locate in the collection.

Returns

true if the System.Windows.Forms.TreeNode is a member of the collection; otherwise, false.

Remarks

This method enables you to determine whether a System.Windows.Forms.TreeNode is a member of the collection before attempting to perform operations on the System.Windows.Forms.TreeNode. You can use this method to confirm that a System.Windows.Forms.TreeNode has been added to or is still a member of the collection.

The amount of time this method takes is proportional to the size of the node collection, so you may want to avoid using it with large collections.

This method checks for reference equality only. You cannot use it to determine whether an equivalent but different node is in the collection.

Note:

One implication of the reference-equality requirement is that you cannot customize the behavior of this method for derived System.Windows.Forms.TreeNode types by overriding the erload:System.Object.Equals method of the System.Windows.Forms.TreeNode class.

Requirements

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