TableCellCollection.Count 屬性

定義

取得 TableCellTableCellCollection 物件的數目。

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

屬性值

Int32

TableCellTableCellCollection 物件的數目。 預設值是 0。

實作

範例

下列範例示範如何使用 Count 屬性來判斷 中的 TableCellCollection 儲存格數目。 請注意,在範例中, CellsTableRow 屬性是 類別的 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 逐一查看集合以判斷上限時,通常會使用 屬性。

適用於

另請參閱