Export (0) Print
Expand All

EventDescriptor Class

Provides information about an event.

System.Object
  System.ComponentModel.MemberDescriptor
    System.ComponentModel.EventDescriptor

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

[ComVisibleAttribute(true)]
[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)]
public abstract class EventDescriptor : MemberDescriptor

The EventDescriptor type exposes the following members.

  NameDescription
Protected methodSupported by the XNA FrameworkEventDescriptor(MemberDescriptor)Initializes a new instance of the EventDescriptor class with the name and attributes in the specified MemberDescriptor.
Protected methodSupported by the XNA FrameworkEventDescriptor(MemberDescriptor, Attribute[])Initializes a new instance of the EventDescriptor class with the name in the specified MemberDescriptor and the attributes in both the MemberDescriptor and the Attribute array.
Protected methodSupported by the XNA FrameworkEventDescriptor(String, Attribute[])Initializes a new instance of the EventDescriptor class with the specified name and attribute array.
Top

  NameDescription
Protected propertySupported by the XNA FrameworkAttributeArrayGets or sets an array of attributes. (Inherited from MemberDescriptor.)
Public propertyAttributesGets the collection of attributes for this member. (Inherited from MemberDescriptor.)
Public propertyCategoryGets the name of the category to which the member belongs, as specified in the CategoryAttribute. (Inherited from MemberDescriptor.)
Public propertySupported by the XNA FrameworkComponentTypeWhen overridden in a derived class, gets the type of component this event is bound to.
Public propertyDescriptionGets the description of the member, as specified in the DescriptionAttribute. (Inherited from MemberDescriptor.)
Public propertyDesignTimeOnlyGets whether this member should be set only at design time, as specified in the DesignOnlyAttribute. (Inherited from MemberDescriptor.)
Public propertySupported by the XNA FrameworkDisplayNameGets the name that can be displayed in a window, such as a Properties window. (Inherited from MemberDescriptor.)
Public propertySupported by the XNA FrameworkEventTypeWhen overridden in a derived class, gets the type of delegate for the event.
Public propertyIsBrowsableGets a value indicating whether the member is browsable, as specified in the BrowsableAttribute. (Inherited from MemberDescriptor.)
Public propertySupported by the XNA FrameworkIsMulticastWhen overridden in a derived class, gets a value indicating whether the event delegate is a multicast delegate.
Public propertySupported by the XNA FrameworkNameGets the name of the member. (Inherited from MemberDescriptor.)
Protected propertySupported by the XNA FrameworkNameHashCodeGets the hash code for the name of the member, as specified in GetHashCode. (Inherited from MemberDescriptor.)
Top

  NameDescription
Public methodSupported by the XNA FrameworkAddEventHandlerWhen overridden in a derived class, binds the event to the component.
Protected methodSupported by the XNA FrameworkCreateAttributeCollectionCreates a collection of attributes using the array of attributes passed to the constructor. (Inherited from MemberDescriptor.)
Public methodSupported by the XNA FrameworkEqualsCompares this instance to the given object to see if they are equivalent. (Inherited from MemberDescriptor.)

In XNA Framework 3.0, this member is inherited from Object.Equals(Object).
Protected methodSupported by the XNA FrameworkFillAttributesWhen overridden in a derived class, adds the attributes of the inheriting class to the specified list of attributes in the parent class. (Inherited from MemberDescriptor.)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeReturns the hash code for this instance. (Inherited from MemberDescriptor.)
Protected methodGetInvocationTargetRetrieves the object that should be used during invocation of members. (Inherited from MemberDescriptor.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkRemoveEventHandlerWhen overridden in a derived class, unbinds the delegate from the component so that the delegate will no longer receive events from the component.
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

An EventDescriptor consists of a name, its attributes, the component that the event is bound to, the event delegate, the type of delegate, and whether the delegate is multicast.

EventDescriptor provides the following abstract properties and methods:

  • ComponentType contains the type of the component this event is declared on.

  • EventType contains the type of delegate for the event.

  • IsMulticast contains a value indicating whether the event delegate is a multicast delegate.

  • AddEventHandler binds the event to a component.

  • RemoveEventHandler unbinds the delegate from the component so that the delegate no longer receives events from the component.

For more information about events, see Raising an Event. For more information about reflection, see the topics in Reflection in the .NET Framework.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. 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 is built upon the example in the EventDescriptorCollection class. It prints the information (category, description, and display name) of each event on a button in a text box. It requires that button1 and textbox1 have been instantiated on a form.

EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Displays each event's information in the collection in a text box. 
foreach (System.ComponentModel.EventDescriptor myEvent in events) {
    textBox1.Text += myEvent.Category + '\n';
    textBox1.Text += myEvent.Description + '\n';
    textBox1.Text += myEvent.DisplayName + '\n';
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft