System.Web
2.0.0.0
System.Object
System.Collections.ICollection
System.Web.UI.IStateManager
The class is used to store and manage a collection of objects in the control. The control uses the class in two of its properties. It stores its root nodes in the property and its selected nodes in the property. The collection is also used for the property to store child nodes (if any).
The class supports several ways to access the items in the collection:
-
Use the indexer to retrieve a object directly at a specific zero-based index.
-
Use the 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.
-
Use the method to copy the contents of the collection into an object.
You can programmatically manage the by adding and removing objects. To add nodes to the collection, use the or method. To remove nodes from the collection, use the , , or method.
When the control is bound to a data source, the and 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 property. If you want to determine whether the collection contains a certain object, use the method. To get the index of a object in the collection, use the method.
Represents a collection of objects in the control. This class cannot be inherited.
Constructor
Use this constructor to initialize a new instance of the class using the default values. This constructor is commonly used when creating a collection of root nodes where a parent node (or owner) is not required.
When creating a collection of non-root nodes, you should use the overloaded constructor that takes the parameter, instead of this constructor, to specify the parent node.
This constructor is used primarily by control developers.
Initializes a new instance of the class using the default values.
2.0.0.0
Constructor
Use this constructor to initialize a new instance of the class using the specified parent node (or owner). This constructor is commonly used when creating a collection of non-root nodes where you need to specify the parent node.
When creating a collection of root nodes, consider using the default constructor because root nodes do not have a parent node.
This constructor is used primarily by control developers.
Initializes a new instance of the class using the specified parent node (or owner).
The object that represents the parent node of the collection.
2.0.0.0
Method
System.Void
Use the method to append the specified object to the end of the .
The allows you to add null references (Nothing in Visual Basic), as well as duplicate objects.
As an alternative, you can insert a object in the at a specific index by using the method.
Appends the specified object to the end of the object.
The object to append.
2.0.0.0
Method
System.Void
Use the method to insert the specified object in the at the specified zero-based index.
The allows you to insert null references (Nothing in Visual Basic), as well as duplicate objects.
As an alternative, you can append a object to the end of the by using the method.
Inserts the specified object in a object at the specified index location.
The zero-based index location at which to insert the object.
The object to add.
2.0.0.0
Method
System.Void
Use the method to remove every object from the .
To remove an individual node from the collection, use the or method.
Empties the object.
2.0.0.0
Method
System.Boolean
To be added.
Use the method to determine whether a object is contained in the . This method is commonly used to test for the existence of a object before performing a task, such as adding or removing the node from the collection.
Determines whether the specified object is in the collection.
true if the specified object is contained in the collection; otherwise, false.
2.0.0.0
Method
System.Void
Use the method to copy the contents of the into the specified zero-based object. Items are copied starting at the specified index of the target array. With the object, you can then use array syntax to access the items in the .
As an alternative, you can also use the method to create an enumerator that can be used to access the items in the collection.
Copies all the items from the object to a compatible one-dimensional array of objects, starting at the specified index in the target array.
A zero-based array of objects that receives the copied items from the .
The position in the target array at which to start receiving the copied content.
2.0.0.0
Property
System.Int32
To be added.
Use the property to determine the number of items in a . This property is commonly used when iterating through a collection to determine the upper bound of the collection. The property is also commonly used to determine whether a collection is empty.
Gets the number of items in the object.
2.0.0.0
Method
System.Collections.IEnumerator
Use the method to create an enumerator that can be easily iterated through to get each item in the . To get the item currently pointed to in the enumerator, use the property. Use the method to move to the next item. If you need to move the enumerator back to the beginning of the collection, use the method.
After you create an enumerator or use the method, you must call the method. Otherwise, the item represented by the property is undefined.
As an alternative, you can also use the method to create an object that can be used to access the items in the collection. Another alternative is to use a foreach or For Each structure to iterate through the collection.
Returns an enumerator that can be used to iterate through a object.
An enumerator that can be used to iterate through the .
2.0.0.0
Method
System.Int32
To be added.
Use the method to determine the zero-based index of the specified object in the object. If the node is not in the collection, the method returns -1.
If the specified node appears multiple times in the collection, the index of the first occurrence is returned.
Determines the index of the specified object.
The zero-based index of the first occurrence of within the , if found; otherwise, -1.
2.0.0.0
Property
System.Boolean
To be added.
The property is used to indicate whether access to the is synchronized (thread safe). This property is derived from the class and is overridden to always return false.
For more information on the property, see the property of the interface.
Gets a value indicating whether access to the is synchronized (thread safe).
2.0.0.0
Property
System.Web.UI.WebControls.TreeNode
To be added.
To be added.
To be added.
To be added.
2.0.0.0
Method
System.Void
To be added.
Use the method to remove the specified node from the collection. All items that follow that node are then moved up to fill in the vacant position. The indexes of the moved items are also updated.
The can contain null references (Nothing in Visual Basic), as well as duplicate objects.
As an alternative, you can remove a node at a specific index by using the method. You can also remove every node in the collection by using the method.
Removes the specified object from the object.
2.0.0.0
Method
System.Void
Use the method to remove the object at the specified zero-based index location from a . All items that follow that node are then moved up to fill in the vacant position. The indexes of the moved items are also updated.
The can contain null references (Nothing in Visual Basic), as well as duplicate objects.
As an alternative, you can remove a specific object by using the method. You can also remove every node in the collection by using the method.
Removes the object at the specified index location from the object.
The zero-based index location of the node to remove.
2.0.0.0
Property
System.Object
To be added.
The property provides a synchronized version of the that can be used with synchronizing (threading) code.
The property of this class always returns false, which indicates that the class is not synchronized (not thread safe).
Synchronizing code must perform operations on the object of the , not directly on the itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object.
The object returned in this implementation is the object used to store the objects in the collection.
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
For more information on the property, see the property of the interface.
Gets an object that can be used to synchronize access to the object.
2.0.0.0
Method
2.0.0.0
System.Void
Use the method to copy the contents of the into the specified zero-based object. Items are copied starting at the specified index of the target array. With the object, you can then use array syntax to access the items in the .
As an alternative, you can also use the method to create an enumerator that can be used to access the items in the collection.
Copies all the items from the object to a compatible one-dimensional , starting at the specified index in the target array.
A zero-based object that receives the copied items from the .
The position in the target array at which to start receiving the copied content.
Property
2.0.0.0
System.Boolean
To be added.
To be added.
Gets a value indicating whether the object is saving changes to its view state.
Method
2.0.0.0
System.Void
To be added.
Loads the object's previously saved view state.
A that contains the saved view state values.
Method
2.0.0.0
System.Object
To be added.
Saves the changes to view state to a .
The that contains the view state changes.
Method
2.0.0.0
System.Void
After this method has been called on a server control, the property will return true.
Instructs the to track changes to its view state.