EventDescriptorCollection クラス
アセンブリ: System (system.dll 内)

<ComVisibleAttribute(True)> _ Public Class EventDescriptorCollection Implements IList, ICollection, IEnumerable
[ComVisibleAttribute(true)] public class EventDescriptorCollection : IList, ICollection, IEnumerable
[ComVisibleAttribute(true)] public ref class EventDescriptorCollection : IList, ICollection, IEnumerable

EventDescriptorCollection は読み取り専用であり、イベントを追加または削除するためのメソッドは実装していません。これらのメソッドを実装するには、このクラスから継承する必要があります。
EventDescriptorCollection クラスで利用できるプロパティを使用して、コレクションに対してその内容を照会できます。コレクション内の要素の数を確認するには、Count プロパティを使用します。インデックス番号または名前で指定したプロパティを取得するには、Item プロパティを使用します。
また、Find メソッドを使用して、指定した名前のイベントの説明をコレクションから取得できます。
![]() |
---|
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、Synchronization です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。 |

ボタンにかかわるイベントをすべてテキスト ボックスに出力するコード例を次に示します。この例では、button1 と textBox1 がフォーム上でインスタンス化されていることが必要です。
Private Sub MyEventCollection() ' Creates a new collection and assigns it the events for button1. Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1) ' Displays each event in the collection in a text box. Dim myEvent As EventDescriptor For Each myEvent In events textBox1.Text &= myEvent.Name & ControlChars.Cr Next myEvent End Sub 'MyEventCollection
private void MyEventCollection() { // Creates a new collection and assigns it the events for button1. EventDescriptorCollection events = TypeDescriptor.GetEvents(button1); // Displays each event in the collection in a text box. foreach (EventDescriptor myEvent in events) textBox1.Text += myEvent.Name + '\n'; }
private: void MyEventCollection() { // Creates a new collection and assigns it the events for button1. EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 ); // Displays each event in the collection in a text box. for each ( EventDescriptor^ myEvent in events ) { textBox1->Text = String::Concat( textBox1->Text, myEvent->Name, "\n" ); } }
private void MyEventCollection() { // Creates a new collection and assigns it the events for button1. EventDescriptorCollection events = TypeDescriptor.GetEvents(button1); for (int iCtr = 0; iCtr < events.get_Count(); iCtr++) { EventDescriptor myEvent = events.get_Item(iCtr); // Displays each event in the collection in a text box. textBox1.set_Text(textBox1.get_Text() + myEvent.get_Name() + '\n'); } } //MyEventCollection

System.ComponentModel.EventDescriptorCollection


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- EventDescriptorCollection クラスのページへのリンク