Represents a collection of menu items in a Menu control. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|Count||Gets the number of menu items contained in the current object.|
|IsSynchronized||Gets a value indicating whether access to the object is synchronized (thread safe).|
|Item||Gets the MenuItem object at the specified index in the current object.|
|SyncRoot||Gets an object that can be used to synchronize access to the object.|
|Add||Appends the specified MenuItem object to the end of the current object.|
|AddAt||Inserts the specified MenuItem object in the current object at the specified index location.|
|Clear||Removes all items from the current object.|
|Contains||Determines whether the specified MenuItem object is in the collection.|
|CopyTo(Array, Int32)||Copies all the items from the object to a compatible one-dimensional Array, starting at the specified index in the target array.|
|CopyTo(array<MenuItem>, Int32)||Copies all the items from the object to a compatible one-dimensional array of MenuItem objects, starting at the specified index in the target array.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|GetEnumerator||Returns an enumerator that can be used to iterate through the items in the current object.|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|IndexOf||Determines the index of the specified MenuItem object in the collection.|
|Remove||Removes the specified MenuItem object from the object.|
|RemoveAt||Removes the MenuItem object at the specified index location from the current object.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|AsParallel()||Overloaded. Enables parallelization of a query. (Defined by ParallelEnumerable.)|
|AsParallel()||Overloaded. (Defined by ParallelEnumerable.)|
|AsQueryable()||Overloaded. Converts an IEnumerable to an IQueryable. (Defined by Queryable.)|
|AsQueryable()||Overloaded. (Defined by Queryable.)|
|Cast<TResult>()||Overloaded. Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)|
|Cast<TResult>()||Overloaded. (Defined by Enumerable.)|
|OfType<TResult>()||Overloaded. Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)|
|OfType<TResult>()||Overloaded. (Defined by Enumerable.)|
|IStateManager::IsTrackingViewState||Infrastructure. Gets a value that indicates whether the object is saving changes to its view state.|
|IStateManager::LoadViewState||Infrastructure. Loads the object's previously saved view state.|
|IStateManager::SaveViewState||Infrastructure. Saves the changes to view state to an Object.|
|IStateManager::TrackViewState||Infrastructure. Instructs the object to track changes to its view state.|
The class is used to store and manage a collection of MenuItem objects in the Menu control. The Menu control uses the class to store its root menu items in the Items property. This collection is also used for the ChildItems property of a MenuItem object to store a menu item's submenu items (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 the CopyTo method to copy the contents of the collection into an array.
You can programmatically manage a object by adding and removing MenuItem objects. To add menu items to the collection, use the Add or the AddAt method. To remove nodes from the collection, use the Remove, the RemoveAt, or the Clear method.
When the Menu control is bound to a data source, the Items and ChildItems 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 class 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 MenuItem object, use the Contains method. To get the index of a MenuItem object in the collection, use the IndexOf method.
|Walkthrough: Displaying a Menu on Web Pages||Building ASP .NET Web Applications in Visual Studio|
|Walkthrough: Controlling ASP.NET Menus Programmatically||Building ASP .NET Web Applications in Visual Studio|