Partilhar via


EventDescriptorCollection.GetEnumerator Método

Definição

Obtém um enumerador para isso EventDescriptorCollection.

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

Retornos

Um enumerador que implementa IEnumerator.

Implementações

Exemplos

O exemplo de código a seguir obtém um enumerador para os eventos em button1. Ele usa o enumerador para imprimir os nomes dos eventos na coleção. Ele requer isso button1 e textBox1 foi instanciado em um formulário.

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

Comentários

Observação

O HostProtectionAttribute atributo aplicado a essa classe tem o seguinte Resources valor de propriedade: Synchronization. Isso HostProtectionAttribute não afeta aplicativos da área de trabalho (que normalmente são iniciados clicando duas vezes em um ícone, digitando um comando ou inserindo uma URL em um navegador). Para obter mais informações, consulte a HostProtectionAttribute classe ou os atributos de programação e proteção de host do SQL Server.

Aplica-se a

Confira também