HtmlTableRowCollection 클래스

정의

HtmlTableRow 컨트롤의 행을 나타내는 HtmlTable 개체의 컬렉션입니다. 이 클래스는 상속될 수 없습니다.

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

예제

다음 코드 예제에는의 내용을 동적으로 생성 하는 방법을 보여 줍니다.는 HtmlTable 행을 추가 하 여 컨트롤을 HtmlTableRowCollection 컬렉션입니다. 에 Rows 테이블의 속성은는 HtmlTableRowCollection 개체입니다.

<%@ 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)
   {

     // Get the number of rows and columns selected by the user.
     int numrows = Convert.ToInt32(Select1.Value);
     int numcells = Convert.ToInt32(Select2.Value);

     // Iterate through the rows.
     for (int j = 0; j < numrows; j++)
     {

       // Create a new row and add it to the Rows collection.
       HtmlTableRow row = new HtmlTableRow();

       // Provide a different background color for alternating rows.
       if (j % 2 == 1)
         row.BgColor = "Gray";

       // Iterate through the cells of a row.
       for (int i = 0; i < numcells; i++)
       {
         // Create a new cell and add it to the Cells collection.
         HtmlTableCell cell = new HtmlTableCell();
         cell.Controls.Add(new LiteralControl("row " +
                           j.ToString() +
                           ", cell " +
                           i.ToString()));
         row.Cells.Add(cell);
       }
       Table1.Rows.Add(row);
     }
   }

</script>

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

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

      <h3>HtmlTableRowCollection Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black; padding:5"
             cellspacing="0"
             runat="server" />
        
      <hr />

      Select the number of rows and columns to create: <br /><br />

      Table rows:
      <select id="Select1" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

        

      Table cells:
      <select id="Select2" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br /><br />
  
      <input type="submit" 
             value="Generate Table" 
             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)

    Dim i As Integer
    Dim j As Integer
    Dim row As HtmlTableRow
    Dim cell As HtmlTableCell

    ' Get the number of rows and columns selected by the user.
    Dim numrows As Integer = CInt(Select1.Value)
    Dim numcells As Integer = CInt(Select2.Value)

    ' Iterate through the rows.
    For j = 0 To numrows - 1

      ' Create a new row and add it to the Rows collection.
      row = New HtmlTableRow()

      ' Provide a different background color for alternating rows.
      If (j Mod 2) = 1 Then
        row.BgColor = "Gray"
      End If

      ' Iterate through the cells of a row.
      For i = 0 To numcells - 1
           
        ' Create a new cell and add it to the Cells collection.
        cell = New HtmlTableCell()
        cell.Controls.Add(New LiteralControl("row " & _
                                          j.ToString() & _
                                          ", cell " & _
                                          i.ToString()))
        row.Cells.Add(cell)
            
      Next i

      Table1.Rows.Add(row)
         
    Next j
      
  End Sub

</script>

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

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

      <h3>HtmlTableRowCollection Example</h3>

      <table id="Table1" 
             style="border-width:1; border-color:Black; padding:5"
             cellspacing="0"
             runat="server" />
        
      <hr />

      Select the number of rows and columns to create: <br /><br />

      Table rows:
      <select id="Select1" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>

        

      Table cells:
      <select id="Select2" 
              runat="server">

         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
         <option value="4">4</option>
         <option value="5">5</option>

      </select>
       
      <br /><br />
  
      <input type="submit" 
             value="Generate Table" 
             runat="server"/>

   </form>

</body>
</html>

설명

사용 하 여는 HtmlTableRowCollection 프로그래밍 방식으로 컬렉션을 관리 하는 클래스 HtmlTableRow 의 행을 나타내는 개체를 HtmlTable 제어 합니다. 이 클래스는 일반적으로 추가, 제거 또는 행의 내용을 수정 하는 데 사용 됩니다는 HtmlTable 제어 합니다.

참고

HtmlTable 컨트롤에 포함 된 Rows 속성의 컬렉션을 나타내는 HtmlTableRow 개체입니다. 각 HtmlTableRow 테이블의 개별 행을 나타냅니다. HtmlTableRow 포함 된 Cells 속성의 컬렉션을 나타내는 HtmlTableCell 개체입니다. 이러한 개체는 테이블의 개별 셀을 나타냅니다. 개별 셀을 검색 하려면 먼저 가져와야 합니다 HtmlTableRow 에서 셀을 포함 하는 행을 나타내는 개체를 Rows 의 컬렉션을 HtmlTable 컨트롤. 얻을 수 있습니다는 HtmlTableCell 행의 셀을 나타내는 개체를 Cells 의 컬렉션을 HtmlTableRow입니다.

속성

Count

HtmlTableRowCollection 컬렉션의 HtmlTableRow 개체 수를 가져옵니다.

IsReadOnly

HtmlTableRowCollection 컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

HtmlTableRowCollection 컬렉션에 대한 액세스가 동기화되는지 즉, 스레드로부터 안전하게 보호되는지 여부를 나타내는 값을 가져옵니다.

Item[Int32]

HtmlTableRow 컬렉션에서 지정된 인덱스에 있는 HtmlTableRowCollection 개체를 가져옵니다.

SyncRoot

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

메서드

Add(HtmlTableRow)

지정된 HtmlTableRow 개체를 HtmlTableRowCollection 컬렉션의 끝에 추가합니다.

Clear()

HtmlTableRow 컬렉션에서 HtmlTableRowCollection 개체를 모두 제거합니다.

CopyTo(Array, Int32)

배열의 지정된 인덱스부터 시작하여 HtmlTableRowCollection의 항목을 지정된 Array에 복사합니다.

Equals(Object)

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

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

IEnumerator 컬렉션에 모든 HtmlTableRow 개체를 포함하는 HtmlTableRowCollection 구현 개체를 반환합니다.

GetHashCode()

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

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

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

(다음에서 상속됨 Object)
Insert(Int32, HtmlTableRow)

컬렉션의 지정된 위치에 HtmlTableRow 개체를 추가합니다.

MemberwiseClone()

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

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

HtmlTableRow 컬렉션에서 지정된 HtmlTableRowCollection 개체를 제거합니다.

RemoveAt(Int32)

HtmlTableRow 컬렉션에서 지정된 인덱스에 있는 HtmlTableRowCollection 개체를 제거합니다.

ToString()

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

(다음에서 상속됨 Object)

확장 메서드

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보