Condividi tramite


EventDescriptorCollection.GetEnumerator Metodo

Definizione

Ottiene un enumeratore per l'oggetto 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

Restituisce

Enumeratore che implementa IEnumerator.

Implementazioni

Esempio

L'esempio di codice seguente ottiene un enumeratore per gli eventi in button1. Usa l'enumeratore per stampare i nomi degli eventi nell'insieme. Richiede che button1 e textBox1 sia stata creata un'istanza in un modulo.

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

Commenti

Annotazioni

L'attributo HostProtectionAttribute applicato a questa classe ha il valore della proprietà seguente Resources : Synchronization. Non HostProtectionAttribute influisce sulle applicazioni desktop (che in genere vengono avviate facendo doppio clic su un'icona, digitando un comando o immettendo un URL in un browser). Per altre informazioni, vedere la HostProtectionAttribute classe o gli attributi di programmazione e protezione host di SQL Server.

Si applica a

Vedi anche