Table of Contents

Class Menu.MenuItemCollection

Namespace
System.Windows.Forms
Assembly
NetEx.Legacy.WinForms.dll
[ListBindable(false)]
public class Menu.MenuItemCollection : IList, ICollection, IEnumerable
Inheritance
Menu.MenuItemCollection
Implements
Inherited Members

Constructors

MenuItemCollection(Menu)

public MenuItemCollection(Menu owner)

Parameters

owner Menu

Properties

Count

Gets the number of elements contained in the ICollection.

public int Count { get; }

Property Value

int

The number of elements contained in the ICollection.

IsReadOnly

Gets a value indicating whether the IList is read-only.

public bool IsReadOnly { get; }

Property Value

bool

true if the IList is read-only; otherwise, false.

this[int]

public virtual MenuItem this[int index] { get; }

Parameters

index int

Property Value

MenuItem

this[string]

Retrieves the child control with the specified key.

public virtual MenuItem this[string key] { get; }

Parameters

key string

Property Value

MenuItem

Methods

Add(int, MenuItem)

Adds a MenuItem to this menu at the specified index. The item currently at that index, and all items after it, will be moved up one slot. MenuItems can only be contained in one menu at a time, and may not be added more than once to the same menu.

public virtual int Add(int index, MenuItem item)

Parameters

index int
item MenuItem

Returns

int

Add(string)

Adds a new MenuItem to the end of this menu with the specified caption.

public virtual MenuItem Add(string caption)

Parameters

caption string

Returns

MenuItem

Add(string, EventHandler)

Adds a new MenuItem to the end of this menu with the specified caption, and click handler.

public virtual MenuItem Add(string caption, EventHandler onClick)

Parameters

caption string
onClick EventHandler

Returns

MenuItem

Add(string, MenuItem[])

Adds a new MenuItem to the end of this menu with the specified caption, click handler, and items.

public virtual MenuItem Add(string caption, MenuItem[] items)

Parameters

caption string
items MenuItem[]

Returns

MenuItem

Add(MenuItem)

Adds a MenuItem to the end of this menu MenuItems can only be contained in one menu at a time, and may not be added more than once to the same menu.

public virtual int Add(MenuItem item)

Parameters

item MenuItem

Returns

int

AddRange(MenuItem[])

public virtual void AddRange(MenuItem[] items)

Parameters

items MenuItem[]

Clear()

Removes all existing MenuItems from this menu

public virtual void Clear()

Contains(MenuItem)

public bool Contains(MenuItem value)

Parameters

value MenuItem

Returns

bool

ContainsKey(string)

Returns true if the collection contains an item with the specified key, false otherwise.

public virtual bool ContainsKey(string key)

Parameters

key string

Returns

bool

CopyTo(Array, int)

Copies the elements of the ICollection to an Array, starting at a particular Array index.

public void CopyTo(Array dest, int index)

Parameters

dest Array
index int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

index is less than zero.

ArgumentException
   <code class="paramref">array</code> is multidimensional.  

-or-

The number of elements in the source ICollection is greater than the available space from index to the end of the destination array.

-or-

The type of the source ICollection cannot be cast automatically to the type of the destination array.

Find(string, bool)

Searches for Controls by their Name property, builds up an array of all the controls that match.

public MenuItem[] Find(string key, bool searchAllChildren)

Parameters

key string
searchAllChildren bool

Returns

MenuItem[]

GetEnumerator()

Returns an enumerator that iterates through a collection.

public IEnumerator GetEnumerator()

Returns

IEnumerator

An IEnumerator object that can be used to iterate through the collection.

IndexOf(MenuItem)

public int IndexOf(MenuItem value)

Parameters

value MenuItem

Returns

int

IndexOfKey(string)

The zero-based index of the first occurrence of value within the entire CollectionBase, if found; otherwise, -1.

public virtual int IndexOfKey(string key)

Parameters

key string

Returns

int

Remove(MenuItem)

Removes the specified item from this menu. All subsequent items are moved down one slot.

public virtual void Remove(MenuItem item)

Parameters

item MenuItem

RemoveAt(int)

Removes the item at the specified index in this menu. All subsequent items are moved up one slot.

public virtual void RemoveAt(int index)

Parameters

index int

RemoveByKey(string)

Removes the menu iteml with the specified key.

public virtual void RemoveByKey(string key)

Parameters

key string