Бөлісу құралы:


EventDescriptorCollection.GetEnumerator Метод

Определение

Возвращает перечислитель для этого 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

Возвращаемое значение

Перечислитель, реализующий IEnumerator.

Реализации

Примеры

В следующем примере кода возвращается перечислитель для событий button1. Он использует перечислитель для печати имен событий в коллекции. Для этого требуется button1textBox1 создать экземпляр в форме.

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

Комментарии

Замечание

Атрибут, применяемый к этому классу, имеет следующее HostProtectionAttributeResources значение свойства: Synchronization Это HostProtectionAttribute не влияет на классические приложения (которые обычно запускаются путем двойного щелчка значка, ввода команды или ввода URL-адреса в браузере). Дополнительные сведения см. в HostProtectionAttribute разделе "Класс" или "Атрибуты защиты узлов SQL Server".

Применяется к

См. также раздел