HtmlTableRow クラス

HtmlTable コントロールの <tr> HTML 要素を表します。

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

構文

'宣言
Public Class HtmlTableRow
    Inherits HtmlContainerControl
'使用
Dim instance As HtmlTableRow
public class HtmlTableRow : HtmlContainerControl
public ref class HtmlTableRow : public HtmlContainerControl
public class HtmlTableRow extends HtmlContainerControl
public class HtmlTableRow extends HtmlContainerControl
適用できません。

解説

<tr> 要素はテーブルの行を表します。HtmlTableRow クラスを使用して、HtmlTable コントロールの <tr> HTML 要素をプログラムで制御します。

HtmlTableRow クラスを使用すると、行内のセルの背景色、境界線の色、および高さを指定して、テーブル内の行の外観をカスタマイズできます。これらの属性は BgColorBorderColorHeight の各プロパティを使用して設定されます。

Align プロパティと VAlign プロパティを使用すると、行全体のセルの内容の配置を制御できます。Align プロパティはセルの内容の水平方向の配置を制御し、VAlign プロパティは垂直方向の配置を制御します。

このクラスの Cells コレクションを使用することにより、テーブルの行内の各セルにプログラムでアクセスできます。このコレクションを使用すると、内容と同様に各セルのプロパティも制御できます。

HtmlTableRow のインスタンスの初期プロパティ値の一覧については、HtmlTableRow コンストラクタのトピックを参照してください。

トピック 場所
方法 : ASP.NET 構文を使用して HTML サーバー コントロールを Web ページに追加する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : HTML サーバー コントロール プロパティをプログラムで設定する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : ASP.NET 構文を使用して HTML サーバー コントロールを Web ページに追加する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : HTML サーバー コントロール プロパティをプログラムで設定する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : ASP.NET 構文を使用して HTML サーバー コントロールを Web ページに追加する ASP .NET Web アプリケーションの作成
方法 : HTML サーバー コントロール プロパティをプログラムで設定する ASP .NET Web アプリケーションの作成

使用例

HtmlTableRow インスタンスを使用して、HtmlTable コントロール内の行を表す方法を次のコード例に示します。HtmlTableRow をテーブルの Rows コレクションから取得してその内容を変更します。

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTableRow Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTableRow Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color: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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTableRow Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTableRow Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color: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="JScript" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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++)
    {

      // Iterate through the cells of a row.
      for (var j : int =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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTableRow Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>HtmlTableRow Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color: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>

.NET Framework のセキュリティ

  • AspNetHostingPermission  (ホスト環境での動作に必要なアクセス許可)要求値 : LinkDemand; アクセス許可値 : Minimal
  • AspNetHostingPermission  (ホスト環境での動作に必要なアクセス許可)要求値 : InheritanceDemand; アクセス許可値 : Minimal

継承階層

System.Object
   System.Web.UI.Control
     System.Web.UI.HtmlControls.HtmlControl
       System.Web.UI.HtmlControls.HtmlContainerControl
        System.Web.UI.HtmlControls.HtmlTableRow

スレッド セーフ

この型の public static (Visual Basicでは共有) メンバはすべて,スレッド セーフです。インスタンス メンバの場合は,スレッド セーフであるとは限りません。

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

HtmlTableRow メンバ
System.Web.UI.HtmlControls 名前空間
HtmlTable
HtmlTableRowCollection
BgColor
BorderColor
Height
Align
VAlign
Cells

その他の技術情報

HTML サーバー コントロール