ToolStripItemCollection 类

定义

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

public ref class ToolStripItemCollection : System::Windows::Forms::Layout::ArrangedElementCollection, System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class ToolStripItemCollection : System.Windows.Forms.Layout.ArrangedElementCollection, System.Collections.IList
type ToolStripItemCollection = class
    inherit ArrangedElementCollection
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ToolStripItemCollection
Inherits ArrangedElementCollection
Implements IList
继承
ToolStripItemCollection
属性
实现

注解

使用AddRemoveRemoveAt方法可以在集合中添加和移除单个控件。The Add, Remove, and RemoveAt methods enable you to add and remove individual controls from the collection. 你还可以使用AddRangeClear方法来添加或删除集合中的所有控件。You can also use the AddRange or Clear methods to add or remove all the controls from the collection.

可以通过将控件传递ToolStripItem Contains到方法来确定是否为集合的成员。You can determine whether a ToolStripItem is a member of the collection by passing the control into the Contains method. 若要获取集合ToolStripItem中的位置的索引值, 请将该控件传递IndexOf到方法中。To get the index value of the location of a ToolStripItem in the collection, pass the control into the IndexOf method. 可以通过调用CopyTo方法将集合复制到数组中。The collection can be copied into an array by calling the CopyTo method.

构造函数

ToolStripItemCollection(ToolStrip, ToolStripItem[])

用指定的容器 ToolStripItemCollection 和指定的 ToolStrip 控件的数组初始化 ToolStripItem 类的新实例。Initializes a new instance of the ToolStripItemCollection class with the specified container ToolStrip and the specified array of ToolStripItem controls.

属性

Count

获取集合中的元素数。Gets the number of elements in the collection.

(继承自 ArrangedElementCollection)
IsReadOnly

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

Item[Int32]

获取指定索引处的项。Gets the item at the specified index.

Item[String]

获取具有指定名称的项。Gets the item with the specified name.

方法

Add(Image)

将显示指定图像的 ToolStripItem 添加到集合中。Adds a ToolStripItem that displays the specified image to the collection.

Add(String)

将显示指定文本的 ToolStripItem 添加到集合中。Adds a ToolStripItem that displays the specified text to the collection.

Add(String, Image)

将显示指定图像和文本的 ToolStripItem 添加到集合中。Adds a ToolStripItem that displays the specified image and text to the collection.

Add(String, Image, EventHandler)

将显示指定图像和文本并引发 ToolStripItem 事件的 Click 添加到集合中。Adds a ToolStripItem that displays the specified image and text to the collection and that raises the Click event.

Add(ToolStripItem)

将指定的项添加到集合末尾。Adds the specified item to the end of the collection.

AddRange(ToolStripItem[])

ToolStripItem 控件的数组添加到集合中。Adds an array of ToolStripItem controls to the collection.

AddRange(ToolStripItemCollection)

ToolStripItemCollection 添加到当前集合中。Adds a ToolStripItemCollection to the current collection.

Clear()

从集合中移除所有项。Removes all items from the collection.

Contains(ToolStripItem)

确定指定项是否为集合的成员。Determines whether the specified item is a member of the collection.

ContainsKey(String)

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

CopyTo(Array, Int32)

从目标数组的指定索引处开始将此集合的全部内容复制到兼容的一维 ArrayCopies the entire contents of this collection to a compatible one-dimensional Array, starting at the specified index of the target array.

(继承自 ArrangedElementCollection)
CopyTo(ToolStripItem[], Int32)

将集合复制到指定 ToolStripItem 数组的指定位置。Copies the collection into the specified position of the specified ToolStripItem array.

Equals(Object)

确定两个 ArrangedElementCollection 实例是否相等。Determines whether two ArrangedElementCollection instances are equal.

(继承自 ArrangedElementCollection)
Find(String, Boolean)

根据项名称搜索项,并返回所有匹配控件的数组。Searches for items by their name and returns an array of all matching controls.

GetEnumerator()

返回一个用于访问整个集合的枚举数。Returns an enumerator for the entire collection.

(继承自 ArrangedElementCollection)
GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 ArrangedElementCollection)
GetType()

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

(继承自 Object)
IndexOf(ToolStripItem)

检索集合中指定项的索引。Retrieves the index of the specified item in the collection.

IndexOfKey(String)

检索指定项在集合中的第一个匹配项的索引。Retrieves the index of the first occurrence of the specified item within the collection.

Insert(Int32, ToolStripItem)

将指定的项插入集合中的指定索引处。Inserts the specified item into the collection at the specified index.

MemberwiseClone()

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

(继承自 Object)
Remove(ToolStripItem)

从集合中移除指定的项。Removes the specified item from the collection.

RemoveAt(Int32)

从集合中的指定索引处移除项。Removes an item from the specified index in the collection.

RemoveByKey(String)

移除具有指定键的项。Removes the item that has the specified key.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

ICollection.IsSynchronized

有关此成员的说明,请参见 IsSynchronized 属性。For a description of this member, see the IsSynchronized property.

(继承自 ArrangedElementCollection)
ICollection.SyncRoot

有关此成员的说明,请参见 SyncRoot 属性。For a description of this member, see the SyncRoot property.

(继承自 ArrangedElementCollection)
IList.Add(Object)

向集合中添加一项。Adds an item to the collection.

IList.Clear()

从集合中移除所有项。Removes all items from the collection.

IList.Contains(Object)

确定集合中是否包含指定的项。Determines if the collection contains a specified item.

IList.IndexOf(Object)

确定集合中指定项的位置。Determines the location of a specified item in the collection.

IList.Insert(Int32, Object)

将某个项插入到集合中的指定索引处。Inserts an item into the collection at a specified index.

IList.IsFixedSize

获取一个值,该值指示集合是否具有固定大小。Gets a value indicating whether the collection has a fixed size.

IList.Item[Int32]

检索指定索引处的元素。Retrieves the element at the specified index.

IList.Remove(Object)

从集合中移除指定项的第一个匹配项。Removes the first occurrence of a specified item from the collection.

IList.RemoveAt(Int32)

移除集合中指定索引处的项。Removes an item from the collection at a specified index.

扩展方法

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于