EventDescriptorCollection.GetEnumerator メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
この 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のイベントの列挙子を取得します。 列挙子を使用して、コレクション内のイベントの名前を出力します。 フォームで button1 と 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
注釈
注
このクラスに適用される HostProtectionAttribute 属性には、次の Resources プロパティ値があります: Synchronization。 HostProtectionAttributeはデスクトップ アプリケーションには影響しません (通常、アイコンをダブルクリックするか、コマンドを入力するか、ブラウザーで URL を入力します)。 詳細については、 HostProtectionAttribute クラスまたは SQL Server プログラミング属性とホスト保護属性に関するページを参照してください。