TableRowCollection Classe
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
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
- Herança
-
TableRowCollection
- Implementações
Exemplos
O exemplo a seguir demonstra como adicionar linhas programaticamente a uma tabela adicionando TableRow objetos, que representam as linhas da tabela, ao Table controle por meio da Rows propriedade.
<%@ 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>
Comentários
Use essa classe para gerenciar programaticamente uma coleção de TableRow objetos. Essa classe geralmente é usada para adicionar ou remover linhas de um Table controle.
Observação
Um Table controle contém uma Rows coleção que representa uma coleção de TableRow objetos. Cada TableRow uma representa uma linha individual na tabela e contém uma Cells coleção que representa uma coleção de TableCell objetos. Esses TableCell objetos representam as células individuais na tabela. Para obter uma célula individual, primeiro você deve obter um TableRow da Rows coleção de um Table controle. Em seguida, você pode obter um TableCell da Cells coleção do TableRow.
Propriedades
| Nome | Description |
|---|---|
| Count |
Obtém o número de TableRow objetos no TableRowCollection. |
| IsReadOnly |
Obtém um valor que indica se o TableRowCollection valor é somente leitura. |
| IsSynchronized |
Obtém um valor que indica se o TableRowCollection acesso ao é sincronizado (thread-safe). |
| Item[Int32] |
Obtém um TableRow do TableRowCollection índice especificado. |
| SyncRoot |
Obtém o objeto que pode ser usado para sincronizar o TableRowCollectionacesso ao . |
Métodos
| Nome | Description |
|---|---|
| Add(TableRow) |
Acrescenta o objeto especificado TableRow ao final do TableRowCollection. |
| AddAt(Int32, TableRow) |
Adiciona o objeto especificado TableRow ao TableRowCollection local do índice especificado. |
| AddRange(TableRow[]) |
Acrescenta os TableRow objetos da matriz especificada ao final da coleção. |
| Clear() |
Remove todos os TableRow controles do TableRowCollection. |
| CopyTo(Array, Int32) |
Copia os itens do TableRowCollection para o especificado Array, começando com o índice especificado no Array. |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| GetEnumerator() |
Retorna um IEnumerator objeto implementado que contém todos os TableRow objetos dentro do TableRowCollection. |
| GetHashCode() |
Serve como a função de hash padrão. (Herdado de Object) |
| GetRowIndex(TableRow) |
Retorna um valor que representa o índice do especificado TableRow do TableRowCollection. |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Objectatual. (Herdado de Object) |
| Remove(TableRow) |
Remove o especificado TableRow do TableRowCollection. |
| RemoveAt(Int32) |
Remove um TableRow do TableRowCollection índice especificado. |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual. (Herdado de Object) |
Implantações explícitas de interface
| Nome | Description |
|---|---|
| IList.Add(Object) |
Adiciona um objeto à coleção. |
| IList.Contains(Object) |
Determina se o objeto especificado está contido na coleção. |
| IList.IndexOf(Object) |
Pesquisa o objeto especificado e retorna o índice baseado em zero da primeira ocorrência dentro da coleção. |
| IList.Insert(Int32, Object) |
Insere um objeto na coleção no índice especificado. |
| IList.IsFixedSize |
Para obter uma descrição deste membro, consulte IsFixedSize. |
| IList.Item[Int32] |
Para obter uma descrição deste membro, consulte Item[Int32]. |
| IList.Remove(Object) |
Remove um objeto da coleção. |
Métodos de Extensão
| Nome | Description |
|---|---|
| AsParallel(IEnumerable) |
Habilita a paralelização de uma consulta. |
| AsQueryable(IEnumerable) |
Converte um IEnumerable em um IQueryable. |
| Cast<TResult>(IEnumerable) |
Converte os elementos de um IEnumerable para o tipo especificado. |
| OfType<TResult>(IEnumerable) |
Filtra os elementos de um IEnumerable com base em um tipo especificado. |