ToolStripItemCollection Class

Definition

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
[<System.ComponentModel.ListBindable(false)>]
type ToolStripItemCollection = class
    inherit ArrangedElementCollection
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ToolStripItemCollection
Inherits ArrangedElementCollection
Implements IList
Inheritance
ToolStripItemCollection
Attributes
Implements

Remarks

The Add, Remove, and RemoveAt methods enable you to add and remove individual controls from the collection. You can also use the AddRange or Clear methods to add or remove all the controls from the collection.

You can determine whether a ToolStripItem is a member of the collection by passing the control into the Contains method. To get the index value of the location of a ToolStripItem in the collection, pass the control into the IndexOf method. The collection can be copied into an array by calling the CopyTo method.

Constructors

ToolStripItemCollection(ToolStrip, ToolStripItem[])

Initializes a new instance of the ToolStripItemCollection class with the specified container ToolStrip and the specified array of ToolStripItem controls.

Properties

Count

Gets the number of elements in the collection.

(Inherited from ArrangedElementCollection)
IsReadOnly

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.

Methods

Add(Image)

Adds a ToolStripItem that displays the specified image to the collection.

Add(String)

Adds a ToolStripItem that displays the specified text to the collection.

Add(String, Image)

Adds a ToolStripItem that displays the specified image and text to the collection.

Add(String, Image, EventHandler)

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[])

Adds an array of ToolStripItem controls to the collection.

AddRange(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)

Copies the entire contents of this collection to a compatible one-dimensional Array, starting at the specified index of the target array.

(Inherited from ArrangedElementCollection)
CopyTo(ToolStripItem[], Int32)

Copies the collection into the specified position of the specified ToolStripItem array.

Equals(Object)

Determines whether two ArrangedElementCollection instances are equal.

(Inherited from 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.

(Inherited from ArrangedElementCollection)
GetHashCode()

Returns the hash code for this instance.

(Inherited from ArrangedElementCollection)
GetType()

Gets the Type of the current instance.

(Inherited from 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()

Creates a shallow copy of the current Object.

(Inherited from 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()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.IsSynchronized

For a description of this member, see the IsSynchronized property.

(Inherited from ArrangedElementCollection)
ICollection.SyncRoot

For a description of this member, see the SyncRoot property.

(Inherited from 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.

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to