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


このメソッドを使用して、HtmlTableCellCollection コレクションからすべての HtmlTableCell オブジェクトを削除し、Count プロパティを 0 にリセットします。
![]() |
---|
このメソッドは行からセルを削除しますが、テーブルから行を削除することはありません。テーブルから行を削除するには、HtmlTable コントロールの Rows コレクションから、行を表す HtmlTableRow オブジェクトも削除してください。 |

Clear メソッドを使用して、HtmlTableCellCollection コレクションからすべての項目を削除する方法を次のコード例に示します。その後、新しいエントリがコレクションに追加され、HtmlTable コントロールに表示されます。
<%@ Page Language="VB" AutoEventWireup="True" %> <script runat="server"> Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs) ' Clear the cells from the first row and remove the ' row from the table. Table1.Rows(0).Cells.Clear() Table1.Rows.RemoveAt(0) 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 Row 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) { // Clear the cells from the first row and remove the // row from the table. Table1.Rows[0].Cells.Clear(); Table1.Rows.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 Row from Table" onserverclick="Button_Click" runat="server"/> </form> </body> </html>
<%@ Page Language="JScript" AutoEventWireup="True" %> <script runat="server"> function Button_Click(sender : Object, e : EventArgs) { // Clear the cells from the first row and remove the // row from the table. Table1.Rows[0].Cells.Clear(); Table1.Rows.RemoveAt(0); } </script> <html> <head> </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 Row 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlTableCellCollection.Clear メソッドを検索する場合は、下記のリンクをクリックしてください。

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