Represents a collection of events.
Object
EventDescriptorCollection
[Visual Basic] Public Class EventDescriptorCollection Implements ICollection, IEnumerable [C#] public class EventDescriptorCollection : ICollection, IEnumerable [C++] public __gc class EventDescriptorCollection : public ICollection, IEnumerable [JScript] public class EventDescriptorCollection implements ICollection, IEnumerable
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 (EventDescriptorCollection indexer) to get a specific property by index number or by name.
In addition to properties, you can use the Find method to get a description of the event with the specified name from the collection.
Namespace: System.ComponentModel
Assembly: System.dll
The following example prints all the events on a button in a text box. It assumes that Button1 has been instantiated on a form.
[Visual Basic]
Private Sub MyEventCollection() ' Create a new collection and assign it the events for Button1. Dim events As EventDescriptorCollection events = TypeDescriptor.GetEvents(Button1) ' Use myEvent to print the name of each event. Dim myEvent As EventDescriptor For Each myEvent In events TextBox1.Text &= " " & myEvent.Name Next End Sub
EventDescriptorCollection Members | System.ComponentModel Namespace | EventDescriptor | TypeDescriptor