EventDescriptorCollection.GetEnumerator Metoda

Definicja

Pobiera moduł wyliczający dla tego elementu 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

Zwraca

Moduł wyliczający, który implementuje IEnumeratorelement .

Implementuje

Przykłady

Poniższy przykład kodu pobiera moduł wyliczający dla zdarzeń w systemie button1. Używa modułu wyliczającego do drukowania nazw zdarzeń w kolekcji. Wymaga to utworzenia button1textBox1 wystąpienia i utworzenia wystąpienia w formularzu.

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

Uwagi

Uwaga

Atrybut HostProtectionAttribute zastosowany do tej klasy ma następującą Resources wartość właściwości: Synchronization. Atrybut HostProtectionAttribute nie ma wpływu na aplikacje pulpitu (które typowo są uruchamiane przez dwukrotne kliknięcie ikony, wpisanie polecenia albo wprowadzenie adresu URL w przeglądarce). Aby uzyskać więcej informacji, zobacz klasę HostProtectionAttribute lub SQL Server Programowanie i atrybuty ochrony hosta.

Dotyczy

Zobacz też