EventDescriptorCollection.GetEnumerator Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Enumerátort kap ehhez 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
Válaszok
Egy implementáló enumerátor IEnumerator.
Megvalósítás
Példák
Az alábbi példakód egy enumerátort kér le a következő button1eseményekhez: . Az enumerátor használatával nyomtatja ki a gyűjtemény eseményeinek nevét. Ehhez szükség van rá, button1 és textBox1 egy űrlapon lettek példányosítva.
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
Megjegyzések
Note
Az HostProtectionAttribute osztályra alkalmazott attribútum a következő Resources tulajdonságértéket tartalmazza: Synchronization. Ez HostProtectionAttribute nem érinti az asztali alkalmazásokat (amelyek általában egy ikonra duplán kattintva, egy parancs beírásával vagy egy URL-cím beírásával indulnak el a böngészőben). További információ: HostProtectionAttribute osztály vagy SQL Server Programozási és gazdagépvédelmi attribútumok.