EventDescriptorCollection Class
TOC
Collapse the table of content
Expand the table of content

EventDescriptorCollection Class

 

Represents a collection of EventDescriptor objects.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

System.Object
  System.ComponentModel.EventDescriptorCollection

[ComVisibleAttribute(true)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true)]
public class EventDescriptorCollection : ICollection, IEnumerable, 
	IList

NameDescription
System_CAPS_pubmethodEventDescriptorCollection(EventDescriptor[])

Initializes a new instance of the EventDescriptorCollection class with the given array of EventDescriptor objects.

System_CAPS_pubmethodEventDescriptorCollection(EventDescriptor[], Boolean)

Initializes a new instance of the EventDescriptorCollection class with the given array of EventDescriptor objects. The collection is optionally read-only.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of event descriptors in the collection.

System_CAPS_pubpropertyItem[Int32]

Gets or sets the event with the specified index number.

System_CAPS_pubpropertyItem[String]

Gets or sets the event with the specified name.

NameDescription
System_CAPS_pubmethodAdd(EventDescriptor)

Adds an EventDescriptor to the end of the collection.

System_CAPS_pubmethodClear()

Removes all objects from the collection.

System_CAPS_pubmethodContains(EventDescriptor)

Returns whether the collection contains the given EventDescriptor.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodFind(String, Boolean)

Gets the description of the event with the specified name in the collection.

System_CAPS_pubmethodGetEnumerator()

Gets an enumerator for this EventDescriptorCollection.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexOf(EventDescriptor)

Returns the index of the given EventDescriptor.

System_CAPS_pubmethodInsert(Int32, EventDescriptor)

Inserts an EventDescriptor to the collection at a specified index.

System_CAPS_protmethodInternalSort(IComparer)

Sorts the members of this EventDescriptorCollection, using the specified IComparer.

System_CAPS_protmethodInternalSort(String[])

Sorts the members of this EventDescriptorCollection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodRemove(EventDescriptor)

Removes the specified EventDescriptor from the collection.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the EventDescriptor at the specified index from the collection.

System_CAPS_pubmethodSort()

Sorts the members of this EventDescriptorCollection, using the default sort for this collection, which is usually alphabetical.

System_CAPS_pubmethodSort(IComparer)

Sorts the members of this EventDescriptorCollection, using the specified IComparer.

System_CAPS_pubmethodSort(String[])

Sorts the members of this EventDescriptorCollection, given a specified sort order.

System_CAPS_pubmethodSort(String[], IComparer)

Sorts the members of this EventDescriptorCollection, given a specified sort order and an IComparer.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticEmpty

Specifies an empty collection to use, rather than creating a new one with no items. This static field is read-only.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Add(Object)

Adds an item to the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Clear()

Removes all the items from the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Contains(Object)

Determines whether the collection contains a specific value.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.IndexOf(Object)

Determines the index of a specific item in the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Insert(Int32, Object)

Inserts an item to the collection at the specified index.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Remove(Object)

Removes the first occurrence of a specific object from the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.RemoveAt(Int32)

Removes the item at the specified index.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.Count

Gets the number of elements contained in the collection.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

Gets a value indicating whether access to the collection is synchronized.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

Gets an object that can be used to synchronize access to the collection.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.IsFixedSize

Gets a value indicating whether the collection has a fixed size.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.IsReadOnly

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

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.Item[Int32]

Gets or sets the element at the specified index.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

EventDescriptorCollection is read-only; it does not implement methods that add or remove events. You must inherit from this class to implement these methods.

Using the properties available in the EventDescriptorCollection class, you can query the collection about its contents. Use the Count property to determine the number of elements in the collection. Use the Item property to get a specific property by index number or by name.

You can also use the Find method to get a description of the event with the specified name from the collection.

The following code example prints all the events on a button in a text box. It requires that button1 and textBox1 have been instantiated on a form.

private void MyEventCollection() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);

    // Displays each event in the collection in a text box.
    foreach (EventDescriptor myEvent in events)
       textBox1.Text += myEvent.Name + '\n';
 }

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft