System.Web.UI.HtmlControls Namespace HtmlTableCellCollection Class
Returns the table cell object at the specified index from the Cells collection.
In [ C# ], this property is the indexer for the HtmlTableCellCollection class.
[ VB ]
Public Default ReadOnly Property Item ( _
ByVal index As Integer _
) As HtmlTableCell
[ C# ]
public HtmlTableCell this [
int index
] {get;}
[ C++ ]
public: __property HtmlTableCell* get_Item (
int index
);
[ JScript ]
returnValue=HtmlTableCellCollectionObject.Item ( index );
-or-
returnValue=HtmlTableCellCollectionObject ( index );
- index
- An ordinal index value that specifies the table cell object to return.
The specified HtmlTableCell control.
Use this indexer to get an HtmlTableCell from the HtmlTableCellCollection. You can access an HtmlTableCell at a specified index by using simple array notation.
For example, if you have an HtmlTableCellCollection called myCellCollection, you can access the first element in the collection by using the following statement:
HtmlTableCell myCell = myCellCollection [ 0 ];
Dim myCell As HtmlTableCell = myCellCollection ( 0 ) |
|
C# |
VB |
NOTE: The collection is zero-based, meaning the first element in the collection returns an index value of 0.
The following example demonstrates how to use the indexer to retrieve a cell in the HtmlTableCellCollection. The cell is then updated with new content.
// iterate through the rows of the table
for ( int r = 0; r <= myTable.Rows.Count - 1; r++ ) {
// iterate through the cells of a row
for ( int c = 0; c <= myTable.Rows [ r ].Cells.Count - 1; c++ ) {
// change the content of each cell
myTable.Rows [ r ].Cells [ c ].InnerHtml = "Row " + r.ToString ( ) +
", Column " + c.ToString ( );
}
}
HtmlTableCellCollection Members