TableRowCollection.Count Property
Gets the number of TableRow objects in the TableRowCollection.
[Visual Basic] 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;
Property Value
The number of TableRow objects in the TableRowCollection. The default is 0.
Implements
Remarks
Use this property to determine the number of rows in the TableRowCollection. The Count property is often used when iterating through the collection to determine the upper bound.
Example
[Visual Basic, C#, C++] The following example demonstrates how to use the Count property to determine the number of rows in the TableRowCollection. Note that in the example, the Rows property of the Table is an instance of the TableRowCollection class.
[Visual Basic] 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
TableRowCollection Class | TableRowCollection Members | System.Web.UI.WebControls Namespace | TableCell | Table | Rows