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中的单元格数。 请注意,在此示例中, 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 循环访问集合以确定上限时,通常使用此属性。

适用于

另请参阅