Compartir por


EventDescriptorCollection.GetEnumerator Método

Definición

Obtiene un enumerador para este EventDescriptorCollectionobjeto .

public:
 System::Collections::IEnumerator ^ GetEnumerator();
public:
 virtual System::Collections::IEnumerator ^ GetEnumerator();
public System.Collections.IEnumerator GetEnumerator();
member this.GetEnumerator : unit -> System.Collections.IEnumerator
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Function GetEnumerator () As IEnumerator

Devoluciones

Enumerador que implementa IEnumerator.

Implementaciones

Ejemplos

En el ejemplo de código siguiente se obtiene un enumerador para los eventos en button1. Usa el enumerador para imprimir los nombres de los eventos de la colección. Requiere que button1 y textBox1 se hayan creado instancias en un formulario.

private:
   void MyEnumerator()
   {
      // Creates a new collection, and assigns to it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Creates an enumerator.
      IEnumerator^ ie = events->GetEnumerator();
      
      // Prints the name of each event in the collection.
      Object^ myEvent;
      while ( ie->MoveNext() )
      {
         myEvent = ie->Current;
         textBox1->Text = String::Concat( textBox1->Text, myEvent, "\n" );
      }
   }
void MyEnumerator()
{
    // Creates a new collection, and assigns to it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);

    // Creates an enumerator.
    IEnumerator ie = events.GetEnumerator();

    // Prints the name of each event in the collection.
    object myEvent;
    while (ie.MoveNext())
    {
        myEvent = ie.Current;
        textBox1.Text += myEvent.ToString() + '\n';
    }
}
Private Sub MyEnumerator()
    ' Creates a new collection, and assigns to it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Creates an enumerator.
    Dim ie As IEnumerator = events.GetEnumerator()
    
    ' Prints the name of each event in the collection.
    Dim myEvent As Object
    While ie.MoveNext() = True
        myEvent = ie.Current
        textBox1.Text += myEvent.ToString() & ControlChars.Cr
    End While
End Sub

Comentarios

Nota:

El HostProtectionAttribute atributo aplicado a esta clase tiene el siguiente Resources valor de propiedad: Synchronization. No HostProtectionAttribute afecta a las aplicaciones de escritorio (que normalmente se inician haciendo doble clic en un icono, escribiendo un comando o escribiendo una dirección URL en un explorador). Para obtener más información, consulte la clase o los HostProtectionAttributeatributos de programación y protección de host de SQL Server.

Se aplica a

Consulte también