HtmlTableCellCollection.RemoveAt メソッド
アセンブリ: System.Web (system.web.dll 内)



このメソッドを使用して、指定したインデックス位置にある HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。インデックス番号が 0 から始まるため、コレクションの最初の項目のインデックス値は 0 です。
![]() |
---|

RemoveAt メソッドを使用して、指定したインデックス位置にある項目を HtmlTableCellCollection コレクションから削除する方法を次のコード例に示します。この例では HtmlTable コントロールの最初の列からセルを削除します。
<%@ Page Language="VB" AutoEventWireup="True" %> <script runat="server"> Sub Button_Click(ByVal sender As Object, ByVal 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> <html> <head> <title>HtmlTableCellCollection Example</title> </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>
<%@ Page Language="C#" AutoEventWireup="True" %> <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> <html> <head> <title>HtmlTableCellCollection Example</title> </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>
<%@ Page Language="JScript" AutoEventWireup="True" %> <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> <html> <head> <title>HtmlTableCellCollection Example</title> </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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- HtmlTableCellCollection.RemoveAt メソッドのページへのリンク