コレクションの ListItem オブジェクトの数を取得します。
Public Overridable ReadOnly Property Count As Integer Implements _ ICollection.Count
[C#]
public virtual int Count {get;}
[C++]
public: __property virtual int get_Count();
[JScript]
public function get Count() : int;
プロパティ値
コレクションの ListItem オブジェクトの数。
実装
解説
Count プロパティを使用して、 ListItemCollection の ListItem オブジェクトの数を確認します。通常、 Count プロパティは、コレクションを反復処理してコレクションの上限を確認する場合に使用されます。
使用例
<!-- To view this code snippet in a fully-working example, see the
ListItemCollection Class topic. -->
. . .
' Set the number of rows displayed in the ListBox to be
' the number of items in the ListBoxCollection.
ListBox1.Rows = ListBox1.Items.Count
[C#]
<!-- To view this code snippet in a fully-working example, see the
ListItemCollection Class topic. -->
. . .
// Set the number of rows displayed in the ListBox to be
// the number of items in the ListBoxCollection.
ListBox1.Rows = ListBox1.Items.Count;
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
参照
ListItemCollection クラス | ListItemCollection メンバ | System.Web.UI.WebControls 名前空間 | ListItem