This topic has not yet been rated - Rate this topic

EventDescriptorCollection Class

Represents a collection of EventDescriptor objects.

System.Object
  System.ComponentModel.EventDescriptorCollection

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)
[ComVisibleAttribute(true)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true)]
public class EventDescriptorCollection : IList, 
	ICollection, IEnumerable

The EventDescriptorCollection type exposes the following members.

  Name Description
Public method Supported by the XNA Framework EventDescriptorCollection(EventDescriptor[]) Initializes a new instance of the EventDescriptorCollection class with the given array of EventDescriptor objects.
Public method EventDescriptorCollection(EventDescriptor[], Boolean) Initializes a new instance of the EventDescriptorCollection class with the given array of EventDescriptor objects. The collection is optionally read-only.
Top
  Name Description
Public property Supported by the XNA Framework Count Gets the number of event descriptors in the collection.
Public property Supported by the XNA Framework Item[Int32] Gets or sets the event with the specified index number.
Public property Supported by the XNA Framework Item[String] Gets or sets the event with the specified name.
Top
  Name Description
Public method Supported by the XNA Framework Add Adds an EventDescriptor to the end of the collection.
Public method Supported by the XNA Framework Clear Removes all objects from the collection.
Public method Supported by the XNA Framework Contains Returns whether the collection contains the given EventDescriptor.
Public method Supported by the XNA Framework Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Supported by the XNA Framework 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 Supported by the XNA Framework Find Gets the description of the event with the specified name in the collection.
Public method Supported by the XNA Framework GetEnumerator Gets an enumerator for this EventDescriptorCollection.
Public method Supported by the XNA Framework GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Supported by the XNA Framework GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework IndexOf Returns the index of the given EventDescriptor.
Public method Supported by the XNA Framework Insert Inserts an EventDescriptor to the collection at a specified index.
Protected method InternalSort(IComparer) Sorts the members of this EventDescriptorCollection, using the specified IComparer.
Protected method 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.
Protected method Supported by the XNA Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework Remove Removes the specified EventDescriptor from the collection.
Public method Supported by the XNA Framework RemoveAt Removes the EventDescriptor at the specified index from the collection.
Public method Sort() Sorts the members of this EventDescriptorCollection, using the default sort for this collection, which is usually alphabetical.
Public method Sort(IComparer) Sorts the members of this EventDescriptorCollection, using the specified IComparer.
Public method Sort(String[]) Sorts the members of this EventDescriptorCollection, given a specified sort order.
Public method Sort(String[], IComparer) Sorts the members of this EventDescriptorCollection, given a specified sort order and an IComparer.
Public method Supported by the XNA Framework 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 Supported by the XNA Framework Cast<TResult> Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method Supported by the XNA Framework OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
  Name Description
Public field Static member Supported by the XNA Framework Empty Specifies an empty collection to use, rather than creating a new one with no items. This static field is read-only.
Top
  Name Description
Explicit interface implemetation Private method Supported by the XNA Framework ICollection.CopyTo Copies the elements of the collection to an Array, starting at a particular Array index.
Explicit interface implemetation Private property Supported by the XNA Framework ICollection.Count Gets the number of elements contained in the collection.
Explicit interface implemetation Private property Supported by the XNA Framework ICollection.IsSynchronized Gets a value indicating whether access to the collection is synchronized.
Explicit interface implemetation Private property Supported by the XNA Framework ICollection.SyncRoot Gets an object that can be used to synchronize access to the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IEnumerable.GetEnumerator Returns an enumerator that iterates through a collection.
Explicit interface implemetation Private method Supported by the XNA Framework IList.Add Adds an item to the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IList.Clear Removes all the items from the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IList.Contains Determines whether the collection contains a specific value.
Explicit interface implemetation Private method Supported by the XNA Framework IList.IndexOf Determines the index of a specific item in the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IList.Insert Inserts an item to the collection at the specified index.
Explicit interface implemetation Private property Supported by the XNA Framework IList.IsFixedSize Gets a value indicating whether the collection has a fixed size.
Explicit interface implemetation Private property Supported by the XNA Framework IList.IsReadOnly Gets a value indicating whether the collection is read-only.
Explicit interface implemetation Private property Supported by the XNA Framework IList.Item Gets or sets the element at the specified index.
Explicit interface implemetation Private method Supported by the XNA Framework IList.Remove Removes the first occurrence of a specific object from the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IList.RemoveAt Removes the item at the specified index.
Top

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.

Note Note

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

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

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.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