次の方法で共有


TableCellCollection.Count プロパティ

TableCellCollection 内の TableCell オブジェクトの数を取得します。

Public Overridable ReadOnly Property Count As Integer  Implements _   ICollection.Count
[C#]
public virtual int Count {get;}
[C++]
public: __property virtual int get_Count();
[JScript]
public function get Count() : int;

プロパティ値

TableCellCollection 内の TableCell オブジェクトの数。既定値は 0 です。

実装

ICollection.Count

解説

このプロパティを使用して、 TableCellCollection 内のセルの数を確認します。通常、 Count プロパティは、コレクションを反復処理して上限を確認する場合に使用されます。

使用例

[Visual Basic, C#, C++] Count プロパティを使用して、 TableCellCollection 内のセル数を確認する方法の例を次に示します。この例では、 TableRowCells プロパティは、 TableCellCollection クラスのインスタンスです。

 
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


[C#] 
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() + ")";
                
       }            
    }
 
 }
 

[C++] 
void Button_Click_Coord(Object* /*sender*/, EventArgs* /*e*/)
 {

    for (int i=0; i<Table1->Rows->Count; i++)
    {
       for (int j=0; j<Table1->Rows->Item[i]->Cells->Count; j++)
       {

          Table1->Rows->Item[i]->Cells->Item[j]->Text = String::Format( S"({0}, {1})", __box(j), __box(i));

       }
    }

 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

TableCellCollection クラス | TableCellCollection メンバ | System.Web.UI.WebControls 名前空間 | TableCell | TableRow | Cells