HtmlTableCell 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
HtmlTableCell 클래스의 새 인스턴스를 초기화합니다.
오버로드
| Name | Description |
|---|---|
| HtmlTableCell() |
기본값을 사용하여 클래스의 새 인스턴스를 HtmlTableCell 초기화합니다. |
| HtmlTableCell(String) |
지정된 태그 이름을 사용하여 클래스의 HtmlTableCell 새 인스턴스를 초기화합니다. |
HtmlTableCell()
기본값을 사용하여 클래스의 새 인스턴스를 HtmlTableCell 초기화합니다.
public:
HtmlTableCell();
public HtmlTableCell();
Public Sub New ()
예제
다음 코드 예제에서는 컨트롤을 사용 하 고 웹 페이지에 테이블을 배치 하는 HtmlTable 컨트롤 HtmlTableCell 의 인스턴스를 만드는 방법을 보여 줍니다. 컨트롤의 매개 변수 없는 생성자를 사용하여 요소를 만드는 HtmlTableCell 방법을 <td> 확인합니다. 반면 문자열 매개 변수를 사용하는 오버로드된 생성자는 리터럴 문자열 "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 의 인스턴스를 만드는 방법을 보여 줍니다. 컨트롤의 매개 변수 없는 생성자를 사용하여 요소를 만드는 HtmlTableCell 방법을 <td> 확인합니다. 반면 문자열 매개 변수를 사용하는 오버로드된 생성자는 리터럴 "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 . |