New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

A collection of RadMenuItem objects in a RadMenu control.

The RadMenuItemCollection class represents a collection of RadMenuItem objects. The RadMenuItem objects in turn represent menu items within a RadMenu control.

  • Use the this[int] to programmatically retrieve a single RadMenuItem from the collection, using array notation.
  • Use the Count property to determine the total number of menu items in the collection.
  • Use the Add(RadMenuItem) method to add menu items in the collection.
  • Use the Remove(RadMenuItem) method to remove menu items from the collection.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class RadMenuItemCollection : ControlItemCollection, IList, ICollection, IStateManager, IList<RadMenuItem>, ICollection<RadMenuItem>, IEnumerable<RadMenuItem>, IEnumerable

Inheritance: objectStateManagedCollectionControlItemCollectionRadMenuItemCollection

Implements: ICollectionICollection<RadMenuItem>IEnumerableIEnumerable<RadMenuItem>IListIList<RadMenuItem>IStateManager...

Inherited Members ControlItemCollection.VisibleChildren<T>()ControlItemCollection.Add(ControlItem)ControlItemCollection.Contains(ControlItem)ControlItemCollection.CopyTo(ControlItem[], int)ControlItemCollection.AddRange(IEnumerable<ControlItem>)ControlItemCollection.IndexOf(ControlItem)ControlItemCollection.Insert(int, ControlItem)ControlItemCollection.Remove(ControlItem)ControlItemCollection.FindChild<TControlItem>(Predicate<TControlItem>)ControlItemCollection.FindChildByText<TControlItem>(string)ControlItemCollection.FindChildByValue<TControlItem>(string)ControlItemCollection.FindChildByAttribute<TControlItem>(string, string)ControlItemCollection.FindChildByValue<TControlItem>(string, bool)ControlItemCollection.FindChildByText<TControlItem>(string, bool)ControlItemCollection.AddItemToParentControls(int, ControlItem)ControlItemCollection.OnInsertComplete(int, object)ControlItemCollection.OnRemoveComplete(int, object)ControlItemCollection.OnClear()ControlItemCollection.SetDirtyObject(object)ControlItemCollection.ParentControlItemCollection.VisibleItemsControlItemCollection.ListStateManagedCollection.Clear()StateManagedCollection.CopyTo(Array, int)StateManagedCollection.CreateKnownType(int)StateManagedCollection.GetEnumerator()StateManagedCollection.GetKnownTypes()StateManagedCollection.OnClearComplete()StateManagedCollection.OnValidate(object)StateManagedCollection.OnInsert(int, object)StateManagedCollection.OnRemove(int, object)StateManagedCollection.SetDirty()StateManagedCollection.Countobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

Initializes a new instance of the RadMenuItemCollection class.

C#
public RadMenuItemCollection(Control parent)
Parameters:parentControl

The owner of the collection.

Properties

Gets the RadMenuItem object at the specified index in the current RadMenuItemCollection.

C#
public RadMenuItem this[int index] { get; set; }
Parameters:indexint

The zero-based index of the RadMenuItem to retrieve.

Property Value:

The RadMenuItem at the specified index in the current RadMenuItemCollection.

Methods

Appends the specified RadMenuItem object to the end of the current RadMenuItemCollection.

C#
public virtual void Add(RadMenuItem item)
Parameters:itemRadMenuItem

The RadMenuItem to append to the end of the current RadMenuItemCollection.

Example:
cs-api-definition
RadMenuItem newsItem = new RadMenuItem("News");
RadMenu1.Items.Add(newsItem);

Appends the specified array of RadMenuItem objects to the end of the current RadMenuItemCollection.

C#
public virtual void AddRange(IEnumerable<RadMenuItem> items)
Parameters:itemsIEnumerable<RadMenuItem>

The array of RadMenuItem to append to the end of the current RadMenuItemCollection.

Example:
cs-api-definition
RadMenuItem[] items = new RadMenuItem[] { new RadMenuItem("First"), new RadMenuItem("Second"), new RadMenuItem("Third") };
RadMenu1.Items.AddRange(items);

Determines whether the specified RadMenuItem object is in the current RadMenuItemCollection.

C#
public virtual bool Contains(RadMenuItem item)
Parameters:itemRadMenuItem

The RadMenuItem object to find.

Returns:

bool

true if the current collection contains the specified RadMenuItem object; otherwise, false.

Copies the contents of the current RadMenuItemCollection into the specified array of RadMenuItem objects.

C#
public virtual void CopyTo(RadMenuItem[] array, int index)
Parameters:arrayRadMenuItem[]

The target array.

indexint

The index to start copying from.

Returns the first RadMenuItem that matches the conditions defined by the specified predicate. The predicate should returns a boolean value.

C#
public RadMenuItem FindItem(Predicate<RadMenuItem> match)
Parameters:matchPredicate<RadMenuItem>

The Predicate <> that defines the conditions of the element to search for.

Returns:

RadMenuItem

Example:
cs-api-definition
void Page_Load(object sender, EventArgs e)
{
RadMenu1.FindItem(ItemWithEqualsTextAndValue);
}
private static bool ItemWithEqualsTextAndValue(RadMenuItem item)
{
if (item.Text == item.Value)
{
return true;
}
else
{
return false;
}
}

Searches the items in the collection for a RadMenuItem which contains the specified attribute and attribute value.

C#
public RadMenuItem FindItemByAttribute(string attributeName, string attributeValue)
Parameters:attributeNamestring

The name of the target attribute.

attributeValuestring

The value of the target attribute

Returns:

RadMenuItem

The RadMenuItem that matches the specified arguments. Null (Nothing) is returned if no node is found.

This method is not recursive.

Searches the RadMenu control for the first RadMenuItem with a Text property equal to the specified value.

C#
public RadMenuItem FindItemByText(string text, bool ignoreCase)
Parameters:textstring

The value to search for.

ignoreCasebool

A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).

Returns:

RadMenuItem

A RadMenuItem whose Text property is equal to the specified value.

The method returns the first item matching the search criteria. If no item is matching then null (Nothing in VB.NET) is returned.

Searches the RadMenuItemCollection control for the first RadMenuItem with a Text property equal to the specified value.

C#
public RadMenuItem FindItemByText(string text)
Parameters:textstring

The value to search for.

Returns:

RadMenuItem

A RadMenuItem whose Text property is equal to the specified value.

The method returns the first item matching the search criteria. This method is not recursive. If no item is matching then null (Nothing in VB.NET) is returned.

Searches the RadMenu control for the first RadMenuItem with a Value property equal to the specified value.

C#
public RadMenuItem FindItemByValue(string value, bool ignoreCase)
Parameters:valuestring

The value to search for.

ignoreCasebool

A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).

Returns:

RadMenuItem

A RadMenuItem whose Value property is equal to the specified value.

The method returns the first item matching the search criteria. If no item is matching then null (Nothing in VB.NET) is returned.

Searches the RadMenuItemCollection control for the first RadMenuItem with a Value property equal to the specified value.

C#
public RadMenuItem FindItemByValue(string value)
Parameters:valuestring

The value to search for.

Returns:

RadMenuItem

A RadMenuItem whose Value property is equal to the specified value.

The method returns the first item matching the search criteria. This method is not recursive. If no item is matching then null (Nothing in VB.NET) is returned.

Determines the index of the specified RadMenuItem object in the collection.

C#
public virtual int IndexOf(RadMenuItem item)
Parameters:itemRadMenuItem

The RadMenuItem to locate.

Returns:

int

The zero-based index of item within the current RadMenuItemCollection, if found; otherwise, -1.

Inserts the specified RadMenuItem object in the current RadMenuItemCollection at the specified index location.

C#
public virtual void Insert(int index, RadMenuItem item)
Parameters:indexint

The zero-based index location at which to insert the RadMenuItem.

itemRadMenuItem

The RadMenuItem to insert.

Removes the specified RadMenuItem object from the current RadMenuItemCollection.

C#
public virtual void Remove(RadMenuItem item)
Parameters:itemRadMenuItem

The RadMenuItem object to remove.

Removes the RadMenuItem object at the specified index from the current RadMenuItemCollection.

C#
public void RemoveAt(int index)
Parameters:indexint

The zero-based index of the index to remove.

C#
protected override void SetOwner(ControlItem item)
Parameters:itemControlItem

Overrides: ControlItemCollection.SetOwner(ControlItem)