EventDescriptorCollection EventDescriptorCollection EventDescriptorCollection EventDescriptorCollection Class

Definition

Represents a collection of EventDescriptor objects.

public ref class EventDescriptorCollection : System::Collections::IList
[System.Runtime.InteropServices.ComVisible(true)]
public class EventDescriptorCollection : System.Collections.IList
type EventDescriptorCollection = class
    interface ICollection
    interface IList
    interface IEnumerable
Public Class EventDescriptorCollection
Implements IList
Inheritance
EventDescriptorCollectionEventDescriptorCollectionEventDescriptorCollectionEventDescriptorCollection
Attributes
Implements

Examples

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.
      for each ( EventDescriptor^ myEvent in events )
      {
         textBox1->Text = String::Concat( textBox1->Text, myEvent->Name, "\n" );
      }
   }
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';
 }

Private Sub MyEventCollection()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Displays each event in the collection in a text box.
    Dim myEvent As EventDescriptor
    For Each myEvent In  events
        textBox1.Text &= myEvent.Name & ControlChars.Cr
    Next myEvent
End Sub 'MyEventCollection 

Remarks

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[String] 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.

Constructors

EventDescriptorCollection(EventDescriptor[]) EventDescriptorCollection(EventDescriptor[]) EventDescriptorCollection(EventDescriptor[]) EventDescriptorCollection(EventDescriptor[])

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

EventDescriptorCollection(EventDescriptor[], Boolean) EventDescriptorCollection(EventDescriptor[], Boolean) EventDescriptorCollection(EventDescriptor[], Boolean) EventDescriptorCollection(EventDescriptor[], Boolean)

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

Fields

Empty Empty Empty Empty

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

Properties

Count Count Count Count

Gets the number of event descriptors in the collection.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets or sets the event with the specified index number.

Item[String] Item[String] Item[String] Item[String]

Gets or sets the event with the specified name.

Methods

Add(EventDescriptor) Add(EventDescriptor) Add(EventDescriptor) Add(EventDescriptor)

Adds an EventDescriptor to the end of the collection.

Clear() Clear() Clear() Clear()

Removes all objects from the collection.

Contains(EventDescriptor) Contains(EventDescriptor) Contains(EventDescriptor) Contains(EventDescriptor)

Returns whether the collection contains the given EventDescriptor.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Find(String, Boolean) Find(String, Boolean) Find(String, Boolean) Find(String, Boolean)

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

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Gets an enumerator for this EventDescriptorCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(EventDescriptor) IndexOf(EventDescriptor) IndexOf(EventDescriptor) IndexOf(EventDescriptor)

Returns the index of the given EventDescriptor.

Insert(Int32, EventDescriptor) Insert(Int32, EventDescriptor) Insert(Int32, EventDescriptor) Insert(Int32, EventDescriptor)

Inserts an EventDescriptor to the collection at a specified index.

InternalSort(IComparer) InternalSort(IComparer) InternalSort(IComparer) InternalSort(IComparer)

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

InternalSort(String[]) InternalSort(String[]) InternalSort(String[]) InternalSort(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.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(EventDescriptor) Remove(EventDescriptor) Remove(EventDescriptor) Remove(EventDescriptor)

Removes the specified EventDescriptor from the collection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the EventDescriptor at the specified index from the collection.

Sort() Sort() Sort() Sort()

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

Sort(IComparer) Sort(IComparer) Sort(IComparer) Sort(IComparer)

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

Sort(String[]) Sort(String[]) Sort(String[]) Sort(String[])

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

Sort(String[], IComparer) Sort(String[], IComparer) Sort(String[], IComparer) Sort(String[], IComparer)

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

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

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

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

Gets the number of elements contained in the collection.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

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

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

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

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

Adds an item to the collection.

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

Removes all the items from the collection.

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

Determines whether the collection contains a specific value.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

Determines the index of a specific item in the collection.

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

Inserts an item to the collection at the specified index.

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

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

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

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

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

Gets or sets the element at the specified index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

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

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

Removes the item at the specified index.

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See Also