다음을 통해 공유


HtmlTableCell 생성자

정의

HtmlTableCell 클래스의 새 인스턴스를 초기화합니다.

오버로드

HtmlTableCell()

기본값을 사용하여 HtmlTableCell 클래스의 새 인스턴스를 초기화합니다.

HtmlTableCell(String)

지정된 태그 이름을 사용하여 HtmlTableCell 클래스의 새 인스턴스를 초기화합니다.

HtmlTableCell()

기본값을 사용하여 HtmlTableCell 클래스의 새 인스턴스를 초기화합니다.

public:
 HtmlTableCell();
public HtmlTableCell ();
Public Sub New ()

예제

다음 코드 예제에는 인스턴스를 만드는 방법을 보여 줍니다는 HtmlTable 컨트롤 HtmlTableCell 컨트롤과 웹 페이지에서 테이블을 배치 합니다. 컨트롤의 매개 변수가 없는 생성자를 사용하여 요소를 만드는 <td> 방법을 HtmlTableCell 확인합니다. 반면 문자열 매개 변수를 사용하는 오버로드된 생성자는 리터럴 문자열 "th"와 함께 사용하여 요소를 만듭니 <th> 다.

<%@ 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 Page_Load(Object sender, EventArgs e)
  {

    // Create an instance of an HtmlTable control.
    HtmlTable table = new HtmlTable();
    table.Border = 1;
    table.CellPadding = 3;

    // Populate the HtmlTable control by adding rows to it. 
    for (int rowcount = 0; rowcount < 5; rowcount++)
    {
      // Create a new HtmlTableRow control.
      HtmlTableRow row = new HtmlTableRow();

      // Add cells to the HtmlTableRow control.
      for (int cellcount = 0; cellcount < 4; cellcount++)
      {
        // Define a new HtmlTableCell control.
        HtmlTableCell cell;

        // Create table header cells for the 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 HtmlTableRow Cells collection. 
        row.Cells.Add(cell);

      }

      // Add the row to the HtmlTable Rows collection.
      table.Rows.Add(row);

    }

    // Add the control to the Controls collection of the 
    // PlaceHolder control.
    Place.Controls.Clear();
    Place.Controls.Add(table);

  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>
<body>

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

</body>
</html>
<%@ 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 Page_Load(ByVal sender As Object, ByVal e As EventArgs)

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

    ' Populate the HtmlTable control by adding rows to it.
    Dim rowcount As Integer
    Dim cellcount As Integer
          
    ' Create the rows of the table.
    For rowcount = 0 To 4

      ' Create a new HtmlTableRow control.
      Dim row As HtmlTableRow = New HtmlTableRow()
            
      ' Add cells to the HtmlTableRow control. 
      For cellcount = 0 To 3
          
        ' Define a new HtmlTableCell control.
        Dim cell As HtmlTableCell

        ' Create table header cells for the 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 HtmlTableRow Cells collection.
        row.Cells.Add(cell)
               
      Next cellcount

      ' Add the row to the HtmlTable Rows collection.
      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>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>  
<body>

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

</body>
</html>

설명

이 생성자를 사용 하 여 만들고의 새 인스턴스를 초기화 하는 HtmlTableCell 클래스입니다. 이 생성자는 만드는 데는 HtmlTableCell 나타내는 개체를 <td> 테이블의 데이터 셀에 대 한 요소입니다.

다음 표에서 인스턴스에 대 한 초기 속성 값을 HtmlTableCell입니다.

속성 초기 값
TagName "Td" 리터럴 문자열입니다.

추가 정보

적용 대상

HtmlTableCell(String)

지정된 태그 이름을 사용하여 HtmlTableCell 클래스의 새 인스턴스를 초기화합니다.

public:
 HtmlTableCell(System::String ^ tagName);
public HtmlTableCell (string tagName);
new System.Web.UI.HtmlControls.HtmlTableCell : string -> System.Web.UI.HtmlControls.HtmlTableCell
Public Sub New (tagName As String)

매개 변수

tagName
String

태그의 요소 이름입니다.

예제

다음 코드 예제에는 인스턴스를 만드는 방법을 보여 줍니다는 HtmlTable 컨트롤 HtmlTableCell 컨트롤과 웹 페이지에서 테이블을 배치 합니다. 컨트롤의 매개 변수가 없는 생성자를 사용하여 요소를 만드는 <td> 방법을 HtmlTableCell 확인합니다. 반면 문자열 매개 변수를 사용하는 오버로드된 생성자는 리터럴 "th"와 함께 사용하여 요소를 만듭니 <th> 다.

<%@ 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 Page_Load(Object sender, EventArgs e)
  {

    // Create an instance of an HtmlTable control.
    HtmlTable table = new HtmlTable();
    table.Border = 1;
    table.CellPadding = 3;

    // Populate the HtmlTable control by adding rows to it. 
    for (int rowcount = 0; rowcount < 5; rowcount++)
    {
      // Create a new HtmlTableRow control.
      HtmlTableRow row = new HtmlTableRow();

      // Add cells to the HtmlTableRow control.
      for (int cellcount = 0; cellcount < 4; cellcount++)
      {
        // Define a new HtmlTableCell control.
        HtmlTableCell cell;

        // Create table header cells for the 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 HtmlTableRow Cells collection. 
        row.Cells.Add(cell);

      }

      // Add the row to the HtmlTable Rows collection.
      table.Rows.Add(row);

    }

    // Add the control to the Controls collection of the 
    // PlaceHolder control.
    Place.Controls.Clear();
    Place.Controls.Add(table);

  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>
<body>

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

</body>
</html>
<%@ 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 Page_Load(ByVal sender As Object, ByVal e As EventArgs)

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

    ' Populate the HtmlTable control by adding rows to it.
    Dim rowcount As Integer
    Dim cellcount As Integer
          
    ' Create the rows of the table.
    For rowcount = 0 To 4

      ' Create a new HtmlTableRow control.
      Dim row As HtmlTableRow = New HtmlTableRow()
            
      ' Add cells to the HtmlTableRow control. 
      For cellcount = 0 To 3
          
        ' Define a new HtmlTableCell control.
        Dim cell As HtmlTableCell

        ' Create table header cells for the 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 HtmlTableRow Cells collection.
        row.Cells.Add(cell)
               
      Next cellcount

      ' Add the row to the HtmlTable Rows collection.
      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>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTable Example</title>
</head>  
<body>

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

</body>
</html>

설명

이 생성자를 사용 하 여 만들고의 새 인스턴스를 초기화 하는 HtmlTableCell 클래스입니다. 만들 수 있습니다는 HtmlTableCell 셀을 나타내는 개체를 HtmlTable 제어 합니다. 만드는 데 흔히 사용 되는 HtmlTableCell 나타내는 개체를 <th> 테이블 머리글 셀에 대 한 요소. 이 생성자를 사용하여 테이블 데이터 셀에 대한 요소를 만들 <td> 수 있지만 일반적으로 매개 변수가 없는 생성자를 사용합니다.

참고

이 생성자를 사용 하면 만들려는 셀 요소를 지정할 수 있지만 <th> 요소인 경우에 셀 요소를 지원 합니다. 향후 호환성을 위해이 생성자를 사용 하면 사용할 수 있는 다른 HTML 셀 요소를 만들 수 있습니다.

다음 표에서 인스턴스에 대 한 초기 속성 값을 HtmlTableCell입니다.

속성 초기 값
TagName tagName 매개 변수의 값입니다.

추가 정보

적용 대상