This topic has not yet been rated - Rate this topic

ToolStripItemCollection Class

Represents a collection of ToolStripItem objects.

System.Object
  System.Windows.Forms.Layout.ArrangedElementCollection
    System.Windows.Forms.ToolStripItemCollection

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[ListBindableAttribute(false)]
[UIPermissionAttribute(SecurityAction.InheritanceDemand, Window = UIPermissionWindow.AllWindows)]
public class ToolStripItemCollection : ArrangedElementCollection, 
	IList, ICollection, IEnumerable

The ToolStripItemCollection type exposes the following members.

  Name Description
Public method ToolStripItemCollection Initializes a new instance of the ToolStripItemCollection class with the specified container ToolStrip and the specified array of ToolStripItem controls.
Top
  Name Description
Public property Count Gets the number of elements in the collection. (Inherited from ArrangedElementCollection.)
Public property IsReadOnly Gets a value indicating whether the ToolStripItemCollection is read-only. (Overrides ArrangedElementCollection.IsReadOnly.)
Public property Item[Int32] Gets the item at the specified index.
Public property Item[String] Gets the item with the specified name.
Top
  Name Description
Public method Add(Image) Adds a ToolStripItem that displays the specified image to the collection.
Public method Add(String) Adds a ToolStripItem that displays the specified text to the collection.
Public method Add(ToolStripItem) Adds the specified item to the end of the collection.
Public method Add(String, Image) Adds a ToolStripItem that displays the specified image and text to the collection.
Public method Add(String, Image, EventHandler) Adds a ToolStripItem that displays the specified image and text to the collection and that raises the Click event.
Public method AddRange(ToolStripItem[]) Adds an array of ToolStripItem controls to the collection.
Public method AddRange(ToolStripItemCollection) Adds a ToolStripItemCollection to the current collection.
Public method Clear Removes all items from the collection.
Public method Contains Determines whether the specified item is a member of the collection.
Public method ContainsKey Determines whether the collection contains an item with the specified key.
Public method 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.)
Public method CopyTo(ToolStripItem[], Int32) Copies the collection into the specified position of the specified ToolStripItem array.
Public method Equals Determines whether two ArrangedElementCollection instances are equal. (Inherited from ArrangedElementCollection.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Find Searches for items by their name and returns an array of all matching controls.
Public method GetEnumerator Returns an enumerator for the entire collection. (Inherited from ArrangedElementCollection.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from ArrangedElementCollection.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IndexOf Retrieves the index of the specified item in the collection.
Public method IndexOfKey Retrieves the index of the first occurrence of the specified item within the collection.
Public method Insert Inserts the specified item into the collection at the specified index.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Remove Removes the specified item from the collection.
Public method RemoveAt Removes an item from the specified index in the collection.
Public method RemoveByKey Removes the item that has the specified key.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public Extension Method AsParallel Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension Method AsQueryable Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension Method Cast<TResult> Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
  Name Description
Explicit interface implemetation Private property ICollection.IsSynchronized For a description of this member, see the ICollection.IsSynchronized property. (Inherited from ArrangedElementCollection.)
Explicit interface implemetation Private property ICollection.SyncRoot For a description of this member, see the ICollection.SyncRoot property. (Inherited from ArrangedElementCollection.)
Explicit interface implemetation Private method IList.Add Adds an item to the collection.
Explicit interface implemetation Private method IList.Clear Removes all items from the collection.
Explicit interface implemetation Private method IList.Contains Determines if the collection contains a specified item.
Explicit interface implemetation Private method IList.IndexOf Determines the location of a specified item in the collection.
Explicit interface implemetation Private method IList.Insert Inserts an item into the collection at a specified index.
Explicit interface implemetation Private property IList.IsFixedSize Gets a value indicating whether the collection has a fixed size.
Explicit interface implemetation Private property IList.Item Retrieves the element at the specified index.
Explicit interface implemetation Private method IList.Remove Removes the first occurrence of a specified item from the collection.
Explicit interface implemetation Private method IList.RemoveAt Removes an item from the collection at a specified index.
Top

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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ