Muokkaa

Jaa


EventDescriptor Class

Definition

Provides information about an event.

public ref class EventDescriptor abstract : System::ComponentModel::MemberDescriptor
public abstract class EventDescriptor : System.ComponentModel.MemberDescriptor
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class EventDescriptor : System.ComponentModel.MemberDescriptor
type EventDescriptor = class
    inherit MemberDescriptor
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptor = class
    inherit MemberDescriptor
Public MustInherit Class EventDescriptor
Inherits MemberDescriptor
Inheritance
EventDescriptor
Attributes

Examples

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.
for each (EventDescriptor^ myEvent in events) {
    textBox1->Text += myEvent->Category + '\n';
    textBox1->Text += myEvent->Description + '\n';
    textBox1->Text += myEvent->DisplayName + '\n';
}
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';
}
Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(Button1)
' Displays each event's information in the collection in a text box.
Dim myEvent As EventDescriptor
For Each myEvent In events
    TextBox1.Text &= myEvent.Category & ControlChars.Cr
    TextBox1.Text &= myEvent.Description & ControlChars.Cr
    TextBox1.Text &= myEvent.DisplayName & ControlChars.Cr
Next myEvent

Remarks

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 Handling and Raising Events. For more information about reflection, see the topics in Reflection.

Constructors

EventDescriptor(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.

EventDescriptor(MemberDescriptor)

Initializes a new instance of the EventDescriptor class with the name and attributes in the specified MemberDescriptor.

EventDescriptor(String, Attribute[])

Initializes a new instance of the EventDescriptor class with the specified name and attribute array.

Properties

AttributeArray

Gets or sets an array of attributes.

(Inherited from MemberDescriptor)
Attributes

Gets the collection of attributes for this member.

(Inherited from MemberDescriptor)
Category

Gets the name of the category to which the member belongs, as specified in the CategoryAttribute.

(Inherited from MemberDescriptor)
ComponentType

When overridden in a derived class, gets the type of component this event is bound to.

Description

Gets the description of the member, as specified in the DescriptionAttribute.

(Inherited from MemberDescriptor)
DesignTimeOnly

Gets whether this member should be set only at design time, as specified in the DesignOnlyAttribute.

(Inherited from MemberDescriptor)
DisplayName

Gets the name that can be displayed in a window, such as a Properties window.

(Inherited from MemberDescriptor)
EventType

When overridden in a derived class, gets the type of delegate for the event.

IsBrowsable

Gets a value indicating whether the member is browsable, as specified in the BrowsableAttribute.

(Inherited from MemberDescriptor)
IsMulticast

When overridden in a derived class, gets a value indicating whether the event delegate is a multicast delegate.

Name

Gets the name of the member.

(Inherited from MemberDescriptor)
NameHashCode

Gets the hash code for the name of the member, as specified in GetHashCode().

(Inherited from MemberDescriptor)

Methods

AddEventHandler(Object, Delegate)

When overridden in a derived class, binds the event to the component.

CreateAttributeCollection()

Creates a collection of attributes using the array of attributes passed to the constructor.

(Inherited from MemberDescriptor)
Equals(Object)

Compares this instance to the given object to see if they are equivalent.

(Inherited from MemberDescriptor)
FillAttributes(IList)

When 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)
GetHashCode()

Returns the hash code for this instance.

(Inherited from MemberDescriptor)
GetInvocationTarget(Type, Object)

Retrieves the object that should be used during invocation of members.

(Inherited from MemberDescriptor)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RemoveEventHandler(Object, Delegate)

When overridden in a derived class, unbinds the delegate from the component so that the delegate will no longer receive events from the component.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also