Share via


HtmlTableRow コンストラクタ

HtmlTableRow クラスの新しいインスタンスを初期化します。

Public Sub New()
[C#]
public HtmlTableRow();
[C++]
public: HtmlTableRow();
[JScript]
public function HtmlTableRow();

解説

このコンストラクタを使用して、 HtmlTableRow クラスの新しいインスタンスを作成し、初期化します。このコンストラクタを使用して、テーブルの行の <tr> 要素を表す HtmlTableRow を作成します。

HtmlTableRow のインスタンスの初期プロパティ値を次の表に示します。

プロパティ 初期値
TagName "tr" リテラル文字列。

使用例

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

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

         ' Create the HtmlTable control.
         Dim table As HtmlTable = New HtmlTable()
         table.Border = 1
         table.CellPadding = 3

         ' Populate the HtmlTable control.

         Dim rowcount As Integer
         Dim cellcount As Integer
          
         ' Create the rows of the table.
         For rowcount=0 to 4

            Dim row As HtmlTableRow = New HtmlTableRow()
            
            ' Create the cells of a row. 
            For cellcount=0 to 3
          
               Dim cell As HtmlTableCell

               ' Create table header cells for first row.
               If rowcount <= 0 Then
             
                  cell = New HtmlTableCell("th")
           
               Else
               
                  cell = New HtmlTableCell()
               
               End If

               ' Create the text for the cell.
               cell.Controls.Add(new LiteralControl( _
                   "row " & rowcount.ToString() & ", " & _
                   "column " & cellcount.ToString()))

               ' Add the cell to the Cells collection of a row. 
               row.Cells.Add(cell)
               
            Next cellcount

            ' Add the row to the Rows collection of the table.
            table.Rows.Add(row)
          
         Next rowcount
 
         ' Add the control to the Controls collection of the 
         ' PlaceHolder control.
         Place.Controls.Clear()
         Place.Controls.Add(table)
         
      End Sub
  
   </script>
  
<body>

   <form runat="server">
  
      <h3> HtmlTable Example </h3> 
  
      <asp:PlaceHolder id="Place" runat="server"/>
  
   </form>

</body>
</html>
 

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
   <script runat="server" >
  
      void Page_Load(Object sender, EventArgs e)
      {

         // Create the HtmlTable control.
         HtmlTable table = new HtmlTable();
         table.Border = 1;
         table.CellPadding = 3;

         // Populate the HtmlTable control.
          
         // Create the rows of the table.
         for(int rowcount=0; rowcount<5; rowcount++)
         {
            HtmlTableRow row = new HtmlTableRow();
            
            // Create the cells of a row. 
            for(int cellcount=0; cellcount<4; cellcount++)
            {
               HtmlTableCell cell;

               // Create table header cells for first row.
               if(rowcount <= 0)
               {
                  cell = new HtmlTableCell("th");
               }
               else
               {
                  cell = new HtmlTableCell();
               }

               // Create the text for the cell.
               cell.Controls.Add(new LiteralControl(
                   "row " + rowcount.ToString() + ", " + 
                   "column " + cellcount.ToString()));

               // Add the cell to the Cells collection of a row. 
               row.Cells.Add(cell);
               
            }

            // Add the row to the Rows collection of the table.
            table.Rows.Add(row);
          
         }
 
         // Add the control to the Controls collection of the 
         // PlaceHolder control.
         Place.Controls.Clear();
         Place.Controls.Add(table);
         
      }
  
   </script>
  
<body>

   <form runat="server">
  
      <h3> HtmlTable Example </h3> 
  
      <asp:PlaceHolder id="Place" runat="server"/>
  
   </form>

</body>
</html>
 

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

HtmlTableRow クラス | HtmlTableRow メンバ | System.Web.UI.HtmlControls 名前空間