TableRowCollection 클래스

정의

TableRow 컨트롤의 한 행을 표시하는 Table 개체의 컬렉션을 캡슐화합니다. 이 클래스는 상속될 수 없습니다.

public ref class TableRowCollection sealed : System::Collections::IList
public sealed class TableRowCollection : System.Collections.IList
type TableRowCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public NotInheritable Class TableRowCollection
Implements IList
상속
TableRowCollection
구현

예제

다음 예제에서는 속성을 통해 Rows 컨트롤에 테이블의 행을 나타내는 개체를 추가하여 프로그래밍 방식으로 테이블에 Table 행을 추가하는 TableRow 방법을 보여 줍니다.

<%@ Page Language="C#" %>

<!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)
    {
        // Generate rows and cells.           
        int numRows = 3;
        int numCells = 2;
        for (int rowNum = 0; rowNum < numRows; rowNum++)
        {
            TableRow rw = new TableRow();
            for (int cellNum = 0; cellNum < numCells; cellNum++)
            {
                TableCell cel = new TableCell();
                cel.Text = String.Format(
                    "row {0}, cell {1}", rowNum, cellNum);
                rw.Cells.Add(cel);
            }
            Table1.Rows.Add(rw);
            Table1.GridLines = GridLines.Both;
            Table1.CellPadding = 4;
            Table1.CellSpacing = 0;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Programmatic Table</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Table Example, constructed programmatically</h3>
        <asp:Table id="Table1" runat="server"/>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!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)
        ' Generate rows and cells.           
        Dim numRows As Integer = 3
        Dim numcells As Integer = 2
        Dim rowNum As Integer
        For rowNum = 0 To numRows - 1
            Dim rw As New TableRow()
            Dim cellNum As Integer
            For cellNum = 0 To numcells - 1
                Dim cel As New TableCell()
                cel.Text = String.Format( _
                    "row {0}, cell {1}", rowNum, cellNum)
                rw.Cells.Add(cel)
            Next cellNum
            Table1.Rows.Add(rw)
        Next rowNum
        Table1.GridLines = GridLines.Both
        Table1.CellPadding = 4
        Table1.CellSpacing = 0
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Programmatic Table</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Table Example, constructed programmatically</h3>
        <asp:Table id="Table1" runat="server"/>
    </div>
    </form>
</body>
</html>

<html>
<head>
    <script language="C#" runat="server">
        void Page_Load(Object sender, EventArgs e) {
            // Generate rows and cells           
            int numrows = 3;
            int numcells = 2;
            for (int j=0; j<numrows; j++) {          
                TableRow r = new TableRow();
                for (int i=0; i<numcells; i++) {
                    TableCell c = new TableCell();
                    c.Text="row " + j.ToString() + ", cell " + i.ToString();
                    r.Cells.Add(c);
                }
                Table1.Rows.Add(r);
            }
        }
    </script>
</head>
<body>
    <h3><font face="Verdana">Table Example, constructed programmatically</font></h3>
    <form runat=server>
        <asp:Table id="Table1"
             runat="server"/>
    </form>
</body>
</html>

설명

이 클래스를 사용하여 개체 컬렉션을 TableRow 프로그래밍 방식으로 관리합니다. 이 클래스는 일반적으로 컨트롤에서 Table 행을 추가하거나 제거하는 데 사용됩니다.

참고

Table 컨트롤에는 Rows 개체 컬렉션을 나타내는 컬렉션 TableRow 이 포함됩니다. 각 TableRow 행은 테이블의 개별 행을 나타내며 개체 컬렉션을 나타내는 컬렉션을 TableCell 포함합니다Cells. 이러한 TableCell 개체는 표의 개별 셀을 나타냅니다. 개별 셀을 얻으려면 먼저 TableRow 컨트롤 컬렉션 Table 에서 Rows 가져와야 합니다. 그런 다음 , 의 TableRow컬렉션에서 Cells 가져올 TableCell 수 있습니다.

속성

Count

TableRowTableRowCollection 개체 수를 가져옵니다.

IsReadOnly

TableRowCollection가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

TableRowCollection에 대한 액세스가 동기화되었는지(스레드로부터 안전한지) 여부를 나타내는 값을 가져옵니다.

Item[Int32]

지정된 인덱스에 있는 TableRow으로부터 TableRowCollection를 가져옵니다.

SyncRoot

TableRowCollection에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

메서드

Add(TableRow)

지정된 TableRow 개체를 TableRowCollection의 끝에 추가합니다.

AddAt(Int32, TableRow)

지정된 TableRow 개체를 TableRowCollection의 지정된 인덱스 위치에 추가합니다.

AddRange(TableRow[])

지정된 배열의 TableRow 개체를 컬렉션의 끝에 추가합니다.

Clear()

TableRow에서 TableRowCollection 컨트롤을 모두 제거합니다.

CopyTo(Array, Int32)

TableRowCollection의 지정된 인덱스에서 시작하여 Array에서 지정된 Array로 항목을 복사합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

IEnumerator에 모든 TableRow 개체를 포함하는 구현된 TableRowCollection 개체를 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetRowIndex(TableRow)

TableRow에 있는 지정된 TableRowCollection의 인덱스를 나타내는 값을 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Remove(TableRow)

TableRow에서 지정된 TableRowCollection을 제거합니다.

RemoveAt(Int32)

지정된 인덱스에 있는 TableRow에서 TableRowCollection를 제거합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

IList.Add(Object)

컬렉션에 개체를 추가합니다.

IList.Contains(Object)

지정된 개체가 컬렉션에 포함되어 있는지 여부를 확인합니다.

IList.IndexOf(Object)

지정된 개체를 검색하고, 컬렉션에서 이 개체가 처음 나타나는 인덱스(0부터 시작)를 반환합니다.

IList.Insert(Int32, Object)

컬렉션의 지정된 인덱스에 개체를 삽입합니다.

IList.IsFixedSize

이 멤버에 대한 설명은 IsFixedSize를 참조하세요.

IList.Item[Int32]

이 멤버에 대한 설명은 Item[Int32]를 참조하세요.

IList.Remove(Object)

컬렉션에서 개체를 제거합니다.

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보