System.Web.UI.WebControls.TreeNodeCollection Class

Represents a collection of System.Web.UI.WebControls.TreeNode objects in the System.Web.UI.WebControls.TreeView control. This class cannot be inherited.

See Also: TreeNodeCollection Members

Syntax

public sealed class TreeNodeCollection : ICollection, System.Web.UI.IStateManager

Remarks

The System.Web.UI.WebControls.TreeNodeCollection class is used to store and manage a collection of System.Web.UI.WebControls.TreeNode objects in the System.Web.UI.WebControls.TreeView control. The System.Web.UI.WebControls.TreeView control uses the System.Web.UI.WebControls.TreeNodeCollection class in two of its properties. It stores its root nodes in the TreeView.Nodes property and its selected nodes in the TreeView.CheckedNodes property. The System.Web.UI.WebControls.TreeNodeCollection collection is also used for the TreeNode.ChildNodes property to store child nodes (if any).

The System.Web.UI.WebControls.TreeNodeCollection class supports several ways to access the items in the collection:

You can programmatically manage the System.Web.UI.WebControls.TreeNodeCollection by adding and removing System.Web.UI.WebControls.TreeNode objects. To add nodes to the collection, use the TreeNodeCollection.Add(TreeNode) or TreeNodeCollection.AddAt(int, TreeNode) method. To remove nodes from the collection, use the TreeNodeCollection.Remove(TreeNode), TreeNodeCollection.RemoveAt(int), or TreeNodeCollection.Clear method.

Note:

When the System.Web.UI.WebControls.TreeView control is bound to a data source, the TreeView.Nodes and TreeNode.ChildNodes collections are automatically populated each time binding occurs. Any changes to the collections between bindings will be lost. To retain these changes, either update the data source or manually rebuild the collection each time you bind.

The System.Web.UI.WebControls.TreeNodeCollection contains properties and methods that allow you to retrieve information about the collection itself. To find out how many items are in the collection, use the TreeNodeCollection.Count property. If you want to determine whether the collection contains a certain System.Web.UI.WebControls.TreeNode object, use the TreeNodeCollection.Contains(TreeNode) method. To get the index of a System.Web.UI.WebControls.TreeNode object in the collection, use the TreeNodeCollection.IndexOf(TreeNode) method.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0