EventDescriptorCollection.GetEnumerator Metodo

Definizione

Ottiene un enumeratore per questo oggetto EventDescriptorCollection.Gets an enumerator for this EventDescriptorCollection.

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

Restituisce

Enumeratore che implementa IEnumerator.An enumerator that implements IEnumerator.

Implementazioni

Esempio

Nell'esempio di codice seguente viene ottenuto un enumeratore per gli eventi in button1.The following code example gets an enumerator for the events on button1. Usa l'enumeratore per stampare i nomi degli eventi nella raccolta.It uses the enumerator to print the names of the events in the collection. È necessario che sia stata creata un'istanza di button1 e textBox1 in un modulo.It requires that button1 and textBox1 have been instantiated on a form.

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() == true )
      {
         myEvent = ie->Current;
         textBox1->Text = String::Concat( textBox1->Text, myEvent, "\n" );
      }
   }
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() == true) {
       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

Nota

L'attributo HostProtectionAttribute applicato a questa classe presenta il valore Resources proprietà seguente: Synchronization.The HostProtectionAttribute attribute applied to this class has the following Resources property value: Synchronization. L'oggetto HostProtectionAttribute non influisce sulle applicazioni desktop, che in genere vengono avviate facendo doppio clic sull'icona, digitando un comando oppure immettendo un URL in un browser.The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). Per ulteriori informazioni, vedere la classe HostProtectionAttribute o gli attributi di programmazione SQL Server e protezione host.For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

Si applica a

Vedi anche