TableCellCollection.Count 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
得到 中TableCellCollection物件TableCell的數量。
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
屬性值
中物件TableCellTableCellCollection的數量。 預設值是 0。
實作
範例
以下範例示範如何利用該 Count 性質來決定 中 TableCellCollection儲存格的數量。 請注意,在範例中, Cells 的 TableRow 性質是類別的實例 TableCellCollection 。
void Button_Click_Coord(object sender, EventArgs e)
{
for (int i=0; i<Table1.Rows.Count; i++)
{
for (int j=0; j<Table1.Rows[i].Cells.Count; j++)
{
Table1.Rows[i].Cells[j].Text = "(" +
j.ToString() + ", " + i.ToString() + ")";
}
}
}
Sub Button_Click_Coord(sender As Object, e As EventArgs)
Dim i As Integer
For i = 0 To Table1.Rows.Count - 1
Dim j As Integer
For j = 0 To (Table1.Rows(i).Cells.Count) - 1
Table1.Rows(i).Cells(j).Text = "(" & j.ToString() & _
", " & i.ToString() & ")"
Next j
Next i
End Sub
備註
利用此性質來決定 中 TableCellCollection的格子數量。 Count此性質常用於在迭代集合以確定上界時。