TableRowCollection 内の TableRow オブジェクトの数を取得します。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public ReadOnly Property Count As Integer
'使用
Dim instance As TableRowCollection
Dim value As Integer
value = instance.Count
public int Count { get; }
public:
virtual property int Count {
int get () sealed;
}
/** @property */
public final int get_Count ()
public final function get Count () : int
適用できません。
プロパティ値
TableRowCollection 内の TableRow オブジェクトの数。既定値は 0 です。
解説
このプロパティを使用して、TableRowCollection 内の行の数を確認します。通常、Count プロパティは、コレクションを反復処理して上限を確認する場合に使用されます。
使用例
Count プロパティを使用して、TableRowCollection 内の行数を確認する方法の例を次に示します。この例では、Table の Rows プロパティは、TableRowCollection クラスのインスタンスです。
Sub Button_Click_Coord(sender As Object, e As EventArgs)
Dim rowNum As Integer
For rowNum = 0 To Table1.Rows.Count - 1
Dim cellNum As Integer
For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1
Table1.Rows(rowNum).Cells(cellNum).Text = _
String.Format("({0}, {1})", rowNum, cellNum)
Next
Next
End Sub
void Button_Click_Coord(object sender, EventArgs e)
{
for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++)
{
for (int cellNum = 0;
cellNum < Table1.Rows[cellNum].Cells.Count; cellNum++)
{
Table1.Rows[rowNum].Cells[cellNum].Text =
String.Format("({0}, {1})", rowNum, cellNum);
}
}
}
void Button_Click_Coord(Object sender, EventArgs e)
{
for (int rowNum = 0; rowNum < table1.get_Rows().get_Count(); rowNum++)
{
for (int cellNum = 0;
cellNum < table1.get_Rows().get_Item(rowNum).get_Cells().get_Count();
cellNum++)
{
table1.get_Rows().get_Item(rowNum).get_Cells().get_Item(cellNum).
set_Text( "(" + System.Convert.ToString(rowNum) + ", "
+ System.Convert.ToString(cellNum) + ")");
}
}
} //Button_Click_Coord
プラットフォーム
Windows 98,Windows Server 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
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
TableRowCollection クラス
TableRowCollection メンバ
System.Web.UI.WebControls 名前空間
TableCell
Table
Table.Rows プロパティ