HtmlTableCell クラス
アセンブリ: System.Web (system.web.dll 内)


<td> 要素はテーブル内のデータ セルを表し、<th> 要素はテーブルの見出しセルを表します。HtmlTableCell クラスを使用して、HtmlTableRow オブジェクトの <td> HTML 要素と <th> HTML 要素をプログラムにより制御します。
HtmlTableCell クラスを使用すると、背景色、境界線の色、高さ、および幅を指定して、テーブル内のセルの外観をカスタマイズできます。これらの属性は BgColor、BorderColor、Height、Width の各プロパティを使用して設定します。
また、内容の垂直方向および水平方向の配置を指定することにより、セルの内容の表示方法を制御できます。また、セルの末尾に到達したときに、内容を自動的に次の行に続けるかどうかをも指定できます。水平方向の配置は Align プロパティで制御しますが、垂直方向の配置は VAlign プロパティで制御します。NoWrap プロパティはテキストの折り返しが無効かどうかを示します。
ColSpan プロパティまたは RowSpan プロパティを使用すると、セルが使用する列または行の数を制御できます。たとえば、ColSpan プロパティを 2 に設定すると、テーブルの列を 2 つ使用するセルを作成できます。
HtmlTableCell のインスタンスの初期プロパティ値の一覧については、HtmlTableCell コンストラクタのトピックを参照してください。
![]() |
---|
このコントロールは、ユーザー入力を表示するために使用できます。ユーザー入力には悪意のあるクライアント スクリプトが含まれている可能性があります。アプリケーションに表示する前に、クライアントから送信された実行スクリプト、SQL ステートメントなどのコードの情報はすべて検査してください。ASP.NET には入力要求の検証機能があり、ユーザー入力の中のスクリプトと HTML をブロックできます。検証サーバー コントロールは、ユーザー入力を査定する目的でも用意されています。詳細については、「検証サーバー コントロール構文」を参照してください。 |

HtmlTableCell を使用してテーブル内のセルの内容を変更するコード例を次に示します。HtmlTable コントロールの Rows コレクションには、テーブルの行 (HtmlTableRow オブジェクト) のコレクションが格納されています。HtmlTableRow オブジェクトの Cells コレクションは行内のセル (HtmlTableCell オブジェクト) のコレクションです。
<%@ 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 ' Iterate through the rows of the table. For i = 0 To Table1.Rows.Count - 1 ' Iterate through the cells of a row. For j = 0 To Table1.Rows(i).Cells.Count - 1 ' Change the inner HTML of the cell. Table1.Rows(i).Cells(j).InnerHtml = "Row " & i.ToString() & _ ", Column " & j.ToString() Next j Next i End Sub </script> <html> <head> <title>HtmlTableCell</title> </head> <body> <form runat="server"> <h3>HtmlTableCell 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="Change Table Contents" 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++) { // Iterate through the cells of a row. for (int j = 0; j <= Table1.Rows[i].Cells.Count - 1; j++) { // Change the inner HTML of the cell. Table1.Rows[i].Cells[j].InnerHtml = "Row " + i.ToString() + ", Column " + j.ToString(); } } } </script> <html> <head> <title>HtmlTableCell</title> </head> <body> <form runat="server"> <h3>HtmlTableCell 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="Change Table Contents" onserverclick="Button_Click" runat="server"/> </form> </body> </html>


System.Web.UI.Control
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.HtmlControls.HtmlContainerControl
System.Web.UI.HtmlControls.HtmlTableCell


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に収録されているすべての辞書からHtmlTableCell クラスを検索する場合は、下記のリンクをクリックしてください。

- HtmlTableCell クラスのページへのリンク