HtmlTableRowCollection.Clear メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HtmlTableRowCollection.Clear メソッドの意味・解説 

HtmlTableRowCollection.Clear メソッド

HtmlTableRowCollection コレクションからすべての HtmlTableRow オブジェクト削除します

名前空間: System.Web.UI.HtmlControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

解説解説
使用例使用例

Clear メソッド使用してHtmlTableRowCollection コレクションからすべての項目を削除する方法次のコード例示しますその後新しいエントリがコレクション追加され、HtmlTable コントロール表示されます。

<%@ Page Language="VB" AutoEventWireup="True"
 %>

<script runat="server">

  Sub Button_Click(ByVal sender As
 Object, ByVal e As EventArgs)
 
    Dim i As Integer
    Dim j As Integer
    Dim row As HtmlTableRow
    Dim cell As HtmlTableCell

    ' Clear the rows from the table.
    Table1.Rows.Clear()

    ' Create a new table.
    ' Iterate through the rows.
    For j = 0 To 4

      ' Create a new row and add it to the Rows collection.
      row = New HtmlTableRow()

      ' Provide a different background color for alternating rows.
      If (j Mod 2) = 1 Then
        row.BgColor = "Gray"
      End If

      ' Iterate through the cells of a row.
      For i = 0 To 4
            
        ' Create a new cell and add it to the Cells collection.
        cell = New HtmlTableCell()
        cell.Controls.Add(New LiteralControl("row
 " & _
                          j.ToString() & _
                          ", cell " & _
                          i.ToString()))
        row.Cells.Add(cell)
      Next i
      Table1.Rows.Add(row)
           
    Next j
      
  End Sub

</script>

<html>
<head>
   <title>HtmlTableRowCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableRowCollection 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="Create New 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 rows from the table.
    Table1.Rows.Clear();

    // Create a new table.
    // Iterate through the rows.
    for (int j = 0; j < 5; j++)
    {

      // Create a new row and add it to the Rows collection.
      HtmlTableRow row = new HtmlTableRow();

      // Provide a different background color for alternating rows.
      if (j % 2 == 1)
        row.BgColor = "Gray";

      // Iterate through the cells of a row.
      for (int i = 0; i < 5; i++)
      {
        // Create a new cell and add it to the Cells collection.
        HtmlTableCell cell = new HtmlTableCell();
        cell.Controls.Add(new LiteralControl("row "
 +
                          j.ToString() +
                          ", cell " +
                          i.ToString()));
        row.Cells.Add(cell);
      }
      Table1.Rows.Add(row);

    }
  }

</script>

<html>
<head>
   <title>HtmlTableRowCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableRowCollection 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="Create New Table"
             onserverclick="Button_Click" 
             runat="server"/>

   </form>

</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlTableRowCollection クラス
HtmlTableRowCollection メンバ
System.Web.UI.HtmlControls 名前空間
HtmlTableCell クラス
HtmlTableRow クラス
HtmlTableRow.Cells プロパティ
Count


このページでは「.NET Framework クラス ライブラリ リファレンス」からHtmlTableRowCollection.Clear メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHtmlTableRowCollection.Clear メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHtmlTableRowCollection.Clear メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HtmlTableRowCollection.Clear メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HtmlTableRowCollection.Clear メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS