HtmlTableCellCollectionとは? わかりやすく解説

HtmlTableCellCollection クラス

HtmlTable コントロールの単一行内のセルを表す HtmlTableCell オブジェクトのコレクション。このクラスは継承できません。

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

Public NotInheritable Class
 HtmlTableCellCollection
    Implements ICollection, IEnumerable
Dim instance As HtmlTableCellCollection
public sealed class HtmlTableCellCollection
 : ICollection, IEnumerable
public ref class HtmlTableCellCollection sealed
 : ICollection, IEnumerable
public final class HtmlTableCellCollection
 implements ICollection, IEnumerable
public final class HtmlTableCellCollection
 implements ICollection, IEnumerable
解説解説
使用例使用例

HtmlTableCellCollection コレクションにセルを追加して、HtmlTable コントロールの内容を動的に生成する方法を次のコード例に示します。HtmlTableRow オブジェクトが表す行の Cells プロパティが HtmlTableCellCollection コレクションであることに注意してください。

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

<script runat="server">
  
  Sub Page_Load(ByVal sender As
 Object, ByVal e As EventArgs)

    Dim i As Integer
    Dim j As Integer
    Dim row As HtmlTableRow
    Dim cell As HtmlTableCell

    ' Get the number of rows and columns selected by the user.
    Dim numrows As Integer
 = CInt(Select1.Value)
    Dim numcells As Integer
 = CInt(Select2.Value)

    ' Iterate through the rows.
    For j = 0 To numrows - 1

      ' 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 numcells - 1
           
        ' 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>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection Example</h3>

      <table id="Table1" 
             cellpadding="5" 
             cellspacing="0" 
             border="1" 
             bordercolor="black" 
             runat="server"/>
        
      <hr>

      Select the number of rows and
 columns to create: <br><br>

      Table rows:
      <select id="Select1" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

      &nbsp;&nbsp;

      Table cells:
      <select id="Select2" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br><br>
  
      <input type="submit" 
             value="Generate Table" 
             runat="server"/>

   </form>

</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>

<script runat="server">

  void Page_Load(Object sender, EventArgs e)
  {

    // Get the number of rows and columns selected by the user.
    int numrows = Convert.ToInt32(Select1.Value);
    int numcells = Convert.ToInt32(Select2.Value);

    // Iterate through the rows.
    for (int j = 0; j < numrows; 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 < numcells; 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>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection Example</h3>

      <table id="Table1" 
             cellpadding="5" 
             cellspacing="0" 
             border="1" 
             bordercolor="black" 
             runat="server"/>
        
      <hr>

      Select the number of rows and columns to create: <br><br>

      Table rows:
      <select id="Select1" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

      &nbsp;&nbsp;

      Table cells:
      <select id="Select2" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br><br>
  
      <input type="submit" 
             value="Generate Table" 
             runat="server"/>

   </form>

</body>
</html>
<%@ Page Language="JScript" AutoEventWireup="True" %>

<script runat="server">

  function Page_Load(sender : Object, e : EventArgs) 
  {

    // Get the number of rows and columns selected by the user.
    var numrows : int = Convert.ToInt32(Select1.Value);
    var numcells : int = Convert.ToInt32(Select2.Value);

    // Iterate through the rows.
    for (var j : int = 0;
 j < numrows; j++) 
    {

      // Create a new row and add it to the Rows collection.
      var row : HtmlTableRow = 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 (var i : int =
 0; i < numcells; i++) 
      {
        // Create a new cell and add it to the Cells collection.
        var cell : HtmlTableCell = 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>HtmlTableCellCollection Example</title>
</head>
<body>

   <form runat="server">

      <h3>HtmlTableCellCollection Example</h3>

      <table id="Table1" 
             cellpadding="5" 
             cellspacing="0" 
             border="1" 
             bordercolor="black" 
             runat="server"/>
        
      <hr>

      Select the number of rows and columns to create: <br><br>

      Table rows:
      <select id="Select1" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

      &nbsp;&nbsp;

      Table cells:
      <select id="Select2" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br><br>
  
      <input type="submit" 
             value="Generate Table" 
             runat="server"/>

   </form>

</body>
</html>
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.HtmlControls.HtmlTableCellCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlTableCellCollection メンバ
System.Web.UI.HtmlControls 名前空間
HtmlTable クラス
HtmlTable.Rows プロパティ
HtmlTableRow
Cells
HtmlTableCell クラス

HtmlTableCellCollection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Count HtmlTableCellCollection コレクション内の HtmlTableCell オブジェクトの数を取得します。
パブリック プロパティ IsReadOnly HtmlTableCellCollection コレクションが読み取り専用かどうかを示す値を取得します。
パブリック プロパティ IsSynchronized HtmlTableCellCollection コレクションへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。
パブリック プロパティ Item 指定したインデックス位置にある HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。
パブリック プロパティ SyncRoot HtmlTableCellCollection コレクションへのアクセスを同期するために使用できるオブジェクトを取得します。
参照参照

関連項目

HtmlTableCellCollection クラス
System.Web.UI.HtmlControls 名前空間
HtmlTable クラス
HtmlTable.Rows プロパティ
HtmlTableRow
Cells
HtmlTableCell クラス

HtmlTableCellCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Add 指定した HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションの末尾に追加します。
パブリック メソッド Clear HtmlTableCellCollection コレクションからすべての HtmlTableCell オブジェクトを削除します。
パブリック メソッド CopyTo HtmlTableCellCollection コレクションから、指定した System.Array に項目をコピーします。コピーは System.Array 内の指定されたインデックス位置から開始します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator HtmlTableCellCollection コレクションのすべての HtmlTableCell オブジェクトを格納する System.Collections.IEnumerator 実装オブジェクトを返します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド Insert 指定した HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションの指定したインデックス位置に追加します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定した HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。
パブリック メソッド RemoveAt 指定したインデックス位置にある HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

HtmlTableCellCollection クラス
System.Web.UI.HtmlControls 名前空間
HtmlTable クラス
HtmlTable.Rows プロパティ
HtmlTableRow
Cells
HtmlTableCell クラス

HtmlTableCellCollection メンバ

HtmlTable コントロールの単一行内のセルを表す HtmlTableCell オブジェクトのコレクション。このクラスは継承できません。

HtmlTableCellCollection データ型で公開されるメンバを以下の表に示します。


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count HtmlTableCellCollection コレクション内の HtmlTableCell オブジェクトの数を取得します。
パブリック プロパティ IsReadOnly HtmlTableCellCollection コレクションが読み取り専用かどうかを示す値を取得します。
パブリック プロパティ IsSynchronized HtmlTableCellCollection コレクションへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。
パブリック プロパティ Item 指定したインデックス位置にある HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。
パブリック プロパティ SyncRoot HtmlTableCellCollection コレクションへのアクセスを同期するために使用できるオブジェクトを取得します。
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Add 指定した HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションの末尾に追加します。
パブリック メソッド Clear HtmlTableCellCollection コレクションからすべての HtmlTableCell オブジェクトを削除します。
パブリック メソッド CopyTo HtmlTableCellCollection コレクションから、指定した System.Array に項目をコピーします。コピーは System.Array 内の指定されたインデックス位置から開始します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator HtmlTableCellCollection コレクションのすべての HtmlTableCell オブジェクトを格納する System.Collections.IEnumerator 実装オブジェクトを返します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド Insert 指定した HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションの指定したインデックス位置に追加します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定した HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。
パブリック メソッド RemoveAt 指定したインデックス位置にある HtmlTableCell オブジェクトを HtmlTableCellCollection コレクションから削除します。
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

HtmlTableCellCollection クラス
System.Web.UI.HtmlControls 名前空間
HtmlTable クラス
HtmlTable.Rows プロパティ
HtmlTableRow
Cells
HtmlTableCell クラス



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「HtmlTableCellCollection」の関連用語

HtmlTableCellCollectionのお隣キーワード

   

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



HtmlTableCellCollectionのページの著作権

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

©2026 GRAS Group, Inc.RSS