Assembly: System.Web (in System.Web.dll)
The class is used to store and manage a collection of TreeNode objects in the TreeView control. The TreeView control uses the class in two of its properties. It stores its root nodes in the Nodes property and its selected nodes in the CheckedNodes property. The collection is also used for the ChildNodes property to store child nodes (if any).
The class supports several ways to access the items in the collection:
Use the GetEnumerator method to create an enumerator that can be used to iterate through the collection.
Use foreach (C#) or For Each (Visual Basic) to iterate through the collection.
You can programmatically manage the by adding and removing TreeNode objects. To add nodes to the collection, use the Add or AddAt method. To remove nodes from the collection, use the Remove, RemoveAt, or Clear method.
When the TreeView control is bound to a data source, the Nodes and 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 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 Count property. If you want to determine whether the collection contains a certain TreeNode object, use the Contains method. To get the index of a TreeNode object in the collection, use the IndexOf method.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.