Menu.MenuItemCollection Menu.MenuItemCollection Menu.MenuItemCollection Menu.MenuItemCollection Class

定义

表示 MenuItem 对象集合。Represents a collection of MenuItem objects.

public: ref class Menu::MenuItemCollection : System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class Menu.MenuItemCollection : System.Collections.IList
type Menu.MenuItemCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class Menu.MenuItemCollection
Implements IList
继承
Menu.MenuItemCollectionMenu.MenuItemCollectionMenu.MenuItemCollectionMenu.MenuItemCollection
属性
实现

注解

此类表示的集合MenuItem中存储的对象MainMenuContextMenu,或MenuItemThis class represents the collection of MenuItem objects stored in a MainMenu, ContextMenu, or MenuItem. 有关MainMenuContextMenu类,该集合表示控件的整个菜单结构。For the MainMenu and ContextMenu classes, this collection represents the entire menu structure for the control. 有关MenuItem类,此集合表示与关联的子菜单项的列表MenuItemFor the MenuItem class, this collection represents the list of submenu items associated with the MenuItem.

AddRemove方法,可以添加和从集合中移除单个菜单项。The Add and Remove methods enable you to add and remove individual menu items from the collection. 此外可以使用Clear方法从集合中移除所有菜单项。You can also use the Clear method to remove all the menu items from the collection.

构造函数

Menu.MenuItemCollection(Menu) Menu.MenuItemCollection(Menu) Menu.MenuItemCollection(Menu) Menu.MenuItemCollection(Menu)

初始化 Menu.MenuItemCollection 类的新实例。Initializes a new instance of the Menu.MenuItemCollection class.

属性

Count Count Count Count

获取一个值,通过该值指示集合中 MenuItem 对象的总数。Gets a value indicating the total number of MenuItem objects in the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个值,该值指示集合是否为只读。Gets a value indicating whether the collection is read-only.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

检索集合中指定索引位置的 MenuItemRetrieves the MenuItem at the specified indexed location in the collection.

Item[String] Item[String] Item[String] Item[String]

获取集合中具有指定键的项。Gets an item with the specified key from the collection.

方法

Add(Int32, MenuItem) Add(Int32, MenuItem) Add(Int32, MenuItem) Add(Int32, MenuItem)

在菜单项集合中的指定索引位置添加以前创建的 MenuItemAdds a previously created MenuItem at the specified index within the menu item collection.

Add(MenuItem) Add(MenuItem) Add(MenuItem) Add(MenuItem)

将以前创建的 MenuItem 添加到当前菜单的末尾。Adds a previously created MenuItem to the end of the current menu.

Add(String) Add(String) Add(String) Add(String)

将具有指定标题的新 MenuItem 添加到当前菜单的末尾。Adds a new MenuItem, to the end of the current menu, with a specified caption.

Add(String, EventHandler) Add(String, EventHandler) Add(String, EventHandler) Add(String, EventHandler)

将具有指定标题和 MenuItem 事件的指定事件处理程序的新 Click 添加到当前菜单的末尾。Adds a new MenuItem to the end of the current menu with a specified caption and a specified event handler for the Click event.

Add(String, MenuItem[]) Add(String, MenuItem[]) Add(String, MenuItem[]) Add(String, MenuItem[])

将具有指定标题、MenuItem 事件处理程序和项的新 Click 添加到该菜单的末尾。Adds a new MenuItem to the end of this menu with the specified caption, Click event handler, and items.

AddRange(MenuItem[]) AddRange(MenuItem[]) AddRange(MenuItem[]) AddRange(MenuItem[])

将以前创建的一组 MenuItem 对象添加到集合。Adds an array of previously created MenuItem objects to the collection.

Clear() Clear() Clear() Clear()

从菜单项集合中移除所有 MenuItem 对象。Removes all MenuItem objects from the menu item collection.

Contains(MenuItem) Contains(MenuItem) Contains(MenuItem) Contains(MenuItem)

确定指定的 MenuItem 是否是集合的成员。Determines if the specified MenuItem is a member of the collection.

ContainsKey(String) ContainsKey(String) ContainsKey(String) ContainsKey(String)

确定集合是否包含具有指定键的项。Determines whether the collection contains an item with the specified key.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

将整个集合复制到现有数组中,从该数组内的指定位置开始复制。Copies the entire collection into an existing array at a specified location within the array.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Find(String, Boolean) Find(String, Boolean) Find(String, Boolean) Find(String, Boolean)

查找具有指定键的项,还可以选择搜索子菜单项Finds the items with the specified key, optionally searching the submenu items

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回可用于循环访问菜单项集合的枚举数。Returns an enumerator that can be used to iterate through the menu item collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IndexOf(MenuItem) IndexOf(MenuItem) IndexOf(MenuItem) IndexOf(MenuItem)

检索集合中特定项的索引。Retrieves the index of a specific item in the collection.

IndexOfKey(String) IndexOfKey(String) IndexOfKey(String) IndexOfKey(String)

查找具有指定键的菜单项的第一个匹配项的索引。Finds the index of the first occurrence of a menu item with the specified key.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(MenuItem) Remove(MenuItem) Remove(MenuItem) Remove(MenuItem)

从菜单项集合中移除指定的 MenuItemRemoves the specified MenuItem from the menu item collection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

从菜单项集合的指定索引位置移除 MenuItemRemoves a MenuItem from the menu item collection at a specified index.

RemoveByKey(String) RemoveByKey(String) RemoveByKey(String) RemoveByKey(String)

从集合中移除具有指定键的菜单项。Removes the menu item with the specified key from the collection.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

有关此成员的说明,请参见 IsSynchronizedFor a description of this member, see IsSynchronized.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

有关此成员的说明,请参见 SyncRootFor a description of this member, see SyncRoot.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

有关此成员的说明,请参见 Add(Object)For a description of this member, see Add(Object).

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

有关此成员的说明,请参见 Contains(Object)For a description of this member, see Contains(Object).

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

有关此成员的说明,请参见 IndexOf(Object)For a description of this member, see IndexOf(Object).

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

有关此成员的说明,请参见 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

有关此成员的说明,请参见 IsFixedSizeFor a description of this member, see IsFixedSize.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

有关此成员的说明,请参见 Item[Int32]For a description of this member, see Item[Int32].

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

有关此成员的说明,请参见 Remove(Object)For a description of this member, see Remove(Object).

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于