This documentation is archived and is not being maintained.

EventDescriptorCollection.Item Property

Gets the specified event.

[C#] In C#, this property is the indexer for the EventDescriptorCollection class.

Overload List

Gets the event with the specified name.

[Visual Basic] Overloads Public Overridable Default ReadOnly Property Item(String) As EventDescriptor
[C#] public virtual EventDescriptor this[string] {get;}
[C++] public: __property virtual EventDescriptor* get_Item(String*);
[JScript] EventDescriptorCollection.Item (String)

Gets the event with the specified index number.

[Visual Basic] Overloads Public Overridable Default ReadOnly Property Item(Integer) As EventDescriptor
[C#] public virtual EventDescriptor this[int] {get;}
[C++] public: __property virtual EventDescriptor* get_Item(int);
[JScript] EventDescriptorCollection.Item (int)

Example

[Visual Basic, C#, C++] The following example uses the Item property to print the name of the EventDescriptor specified by the index number in a text box. Because the index number is zero-based, this example prints the name of the second EventDescriptor. It assumes button1 and textBox1 have been instantiated on a form.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the Item property (EventDescriptorCollection indexer). For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Private Sub PrintIndexItem()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Prints the second event's name.
    textBox1.Text = events(1).ToString()
End Sub 'PrintIndexItem

[C#] 
private void PrintIndexItem() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
 
    // Prints the second event's name.
    textBox1.Text = events[1].ToString();
 }


[C++] 
private:
void PrintIndexItem() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection* events = TypeDescriptor::GetEvents(button1);

    // Prints the second event's name.
    textBox1->Text = events->Item[1]->ToString();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

EventDescriptorCollection Class | EventDescriptorCollection Members | System.ComponentModel Namespace

Show: