コレクション内のイベント記述子の数を取得します。
名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文
'宣言
Public ReadOnly Property Count As Integer
'使用
Dim instance As EventDescriptorCollection
Dim value As Integer
value = instance.Count
public int Count { get; }
public:
property int Count {
int get ();
}
/** @property */
public int get_Count ()
public function get Count () : int
プロパティ値
コレクション内のイベント記述子の数。
解説
Count プロパティは、オブジェクトのコレクションを反復処理するループの限度を設定するために使用できます。コレクションのインデックスが 0 から始まる場合は、ループの上限として Count - 1
を使用します。
注意
このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、Synchronization です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。
使用例
Count プロパティを使用して、button1
に関連付けられたイベントの数を出力するコード例を次に示します。この例では、button1
と textBox1
がフォーム上でインスタンス化されていることが必要です。
Private Sub GetCount()
' Creates a new collection and assigns it the events for button1.
Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
' Prints the number of events on button1 in a text box.
textBox1.Text = events.Count.ToString()
End Sub 'GetCount
private void GetCount() {
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Prints the number of events on button1 in a text box.
textBox1.Text = events.Count.ToString();
}
private:
void GetCount()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
// Prints the number of events on button1 in a text box.
textBox1->Text = events->Count.ToString();
}
private void GetCount()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Prints the number of events on button1 in a text box.
textBox1.set_Text(System.Convert.ToString(events.get_Count()));
} //GetCount
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0
参照
関連項目
EventDescriptorCollection クラス
EventDescriptorCollection メンバ
System.ComponentModel 名前空間
EventDescriptor クラス
TypeDescriptor