EventDescriptorCollection.GetEnumerator Метод
Определение
Возвращает перечислитель для данной коллекции EventDescriptorCollection.Gets an enumerator for this 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.An enumerator that implements IEnumerator.
Реализации
Примеры
В следующем примере кода возвращается перечислитель для событий в button1
.The following code example gets an enumerator for the events on button1
. Он использует перечислитель для вывода имен событий в коллекции.It uses the enumerator to print the names of the events in the collection. Для этого требуется, чтобы button1
textBox1
экземпляр и был создан в форме.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
Комментарии
Примечание
HostProtectionAttributeАтрибут, примененный к этому классу, имеет следующее Resources значение свойства: Synchronization .The HostProtectionAttribute attribute applied to this class has the following Resources property value: Synchronization. Атрибут HostProtectionAttribute не оказывает влияния на настольные приложения (обычно запускаемые двойным щелчком значка, вводом команды или URL-адреса в браузере).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). Дополнительные сведения см. в разделе HostProtectionAttribute класс или SQL Server атрибуты защиты узла.For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.