TableCellCollection.Count プロパティ

定義

TableCell に含まれる TableCellCollection オブジェクトの数を取得します。

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

プロパティ値

Int32

TableCell に含まれる TableCellCollection オブジェクトの数です。 既定値は 0 です。

実装

次の例では、このプロパティTableCellCollectionを使用して、.Count この例では、the の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 、多くの場合、コレクションを反復処理して上限を決定するときに使用されます。

適用対象

こちらもご覧ください