HtmlTableCellCollection.RemoveAt Method
Removes the HtmlTableCell at the specified index from the HtmlTableCellCollection.
[Visual Basic] Public Sub RemoveAt( _ ByVal index As Integer _ ) [C#] public void RemoveAt( int index ); [C++] public: void RemoveAt( int index ); [JScript] public function RemoveAt( index : int );
Parameters
- index
- The index of the HtmlTableCell to remove from the HtmlTableCellCollection.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentOutOfRangeException | The specified index is outside the range of index values in the collection. |
Remarks
Use this method to remove the HtmlTableCell at the specified index from an HtmlTableCellCollection. The index number is zero-based; therefore, the first item in the collection has an index value of 0.
Note If you specify an index that is outside the range of index values, an exception is raised.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the RemoveAt method to remove the item at the specified index from the HtmlTableCellCollection. This example removes the cells from the first column of the HtmlTable control.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub Button_Click(sender As Object, e As EventArgs) Dim i As Integer ' Iterate through the rows of the table. For i=0 To Table1.Rows.Count - 1 ' Remove the cells from the first column. Table1.Rows(i).Cells.RemoveAt(0) Next i End Sub </script> </head> <body> <form runat="server"> <h3>HtmlTableCellCollection Example</h3> <table id="Table1" Border="1" BorderColor="black" runat="server"> <tr> <td> Cell 1 </td> <td> Cell 2 </td> </tr> <tr> <td> Cell 3 </td> <td> Cell 4 </td> </tr> </table> <br><br> <input type="button" value="Remove First Column from Table" OnServerClick = "Button_Click" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void Button_Click(Object sender, EventArgs e) { // Iterate through the rows of the table. for (int i=0; i<=Table1.Rows.Count - 1; i++) { // Remove the cells from the first column. Table1.Rows[i].Cells.RemoveAt(0); } } </script> </head> <body> <form runat="server"> <h3>HtmlTableCellCollection Example</h3> <table id="Table1" Border="1" BorderColor="black" runat="server"> <tr> <td> Cell 1 </td> <td> Cell 2 </td> </tr> <tr> <td> Cell 3 </td> <td> Cell 4 </td> </tr> </table> <br><br> <input type="button" value="Remove First Column from Table" OnServerClick = "Button_Click" runat="server"/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script runat="server"> function Button_Click(sender, e : EventArgs) { // Iterate through the rows of the table. for (var i : int =0; i<=Table1.Rows.Count - 1; i++) { // Remove the cells from the first column. Table1.Rows[i].Cells.RemoveAt(0); } } </script> </head> <body> <form runat="server"> <h3>HtmlTableCellCollection Example</h3> <table id="Table1" Border="1" BorderColor="black" runat="server"> <tr> <td> Cell 1 </td> <td> Cell 2 </td> </tr> <tr> <td> Cell 3 </td> <td> Cell 4 </td> </tr> </table> <br><br> <input type="button" value="Remove First Column from Table" OnServerClick = "Button_Click" runat="server"/> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlTableCellCollection Class | HtmlTableCellCollection Members | System.Web.UI.HtmlControls Namespace | Remove | Cells | HtmlTableRow