Читати англійською Редагувати

Поділитися через


TableRowCollection.Count Property

Definition

Gets the number of TableRow objects in the TableRowCollection.

C#
public int Count { get; }

Property Value

The number of TableRow objects in the TableRowCollection. The default is 0.

Implements

Examples

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.

C#
   void Button_Click_Coord(object sender, EventArgs e) 
   {
       for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++)
       {
           for (int cellNum = 0; 
               cellNum < Table1.Rows[cellNum].Cells.Count; cellNum++)
           {
               Table1.Rows[rowNum].Cells[cellNum].Text = 
                   String.Format("({0}, {1})", rowNum, cellNum);
           }            
       }
   }

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.

Applies to

Продукт Версії
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also