EventDescriptorCollection.GetEnumerator Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient un énumérateur pour ce 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
Retours
Énumérateur qui implémente IEnumerator.
Implémente
Exemples
L’exemple de code suivant obtient un énumérateur pour les événements sur button1. Il utilise l’énumérateur pour imprimer les noms des événements de la collection. Elle exige qu’elle button1 ait textBox1 été instanciée sur un formulaire.
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
Remarques
Note
L’attribut HostProtectionAttribute appliqué à cette classe a la valeur de propriété suivante Resources : Synchronization. Cela HostProtectionAttribute n’affecte pas les applications de bureau (généralement démarrées en double-cliquant sur une icône, en tapant une commande ou en entrant une URL dans un navigateur). Pour plus d’informations, consultez la HostProtectionAttribute classe ou les attributs de programmation et de protection de l’hôte SQL Server.