Sdílet prostřednictvím


EventDescriptorCollection.GetEnumerator Metoda

Definice

Získá enumerátor pro to 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

Návraty

Enumerátor, který implementuje IEnumerator.

Implementuje

Příklady

Následující příklad kódu získá enumerátor pro události on button1. Pomocí enumerátoru vytiskne názvy událostí v kolekci. Vyžaduje vytvoření button1 instance formuláře textBox1 .

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

Poznámky

Poznámka:

Atribut HostProtectionAttribute použitý pro tuto třídu má následující Resources hodnotu vlastnosti: Synchronization. Nemá HostProtectionAttribute vliv na desktopové aplikace (které se obvykle spouští poklikáním na ikonu, zadáním příkazu nebo zadáním adresy URL v prohlížeči). Další informace naleznete v HostProtectionAttribute tématu třídy nebo programování SYSTÉMU SQL Server a atributy ochrany hostitele.

Platí pro

Viz také