Gets the event with the specified name.
[C#] In C#, this member is the indexer for the EventDescriptorCollection class.
[Visual Basic] Overloads Overridable Public Default ReadOnly Property Item( _ ByVal name As String _ ) As EventDescriptor [C#] public EventDescriptor this[ string name ] {virtual get;} [C++] public: __property virtual EventDescriptor* get_Item( String* name ); [JScript] returnValue = EventDescriptorCollectionObject.Item(name); -or- returnValue = EventDescriptorCollectionObject(name);
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.
The EventDescriptor with the specified name, or a null reference (in Visual Basic Nothing) if the event does not exist.
Item property (EventDescriptorCollection indexer)is case-sensitive when searching for names. That is, if two events exist with the names "Ename" and "ename," Item property (EventDescriptorCollection indexer)will find the specific event you name.
The following example uses the Item property (EventDescriptorCollection indexer) to print the type of component for the EventDescriptor specified by the index. It assumes that Button1 has been instantiated on a form.
[Visual Basic]
Private Sub PrintIndexItem2() Dim events As EventDescriptorCollection events = TypeDescriptor.GetEvents(Button1) ' Set a EventDescriptor to the specific event. Dim myEvent As EventDescriptor myEvent = events.Item("KeyDown") ' Print the type of component for the Event. TextBox1.Text = myEvent.ComponentType.ToString End Sub
EventDescriptorCollection Class | EventDescriptorCollection Members | System.ComponentModel Namespace | EventDescriptorCollection.Item Overload List | EventDescriptor | TypeDescriptor