HtmlTable.HtmlTableRowControlCollection Classe

Definição

Representa uma coleção de objetos HtmlTableRow que são as linhas de um controle HtmlTable.Represents a collection of HtmlTableRow objects that are the rows of an HtmlTable control.

protected: ref class HtmlTable::HtmlTableRowControlCollection : System::Web::UI::ControlCollection
protected class HtmlTable.HtmlTableRowControlCollection : System.Web.UI.ControlCollection
Protected Class HtmlTable.HtmlTableRowControlCollection
Inherits ControlCollection
Herança
HtmlTable.HtmlTableRowControlCollection

Exemplos

O exemplo de código a seguir demonstra como criar um personalizado HtmlTable.HtmlTableRowControlCollection que substitui o Add método de forma que quando as linhas são adicionadas a uma tabela, sempre são adicionadas no início da coleção de linhas da tabela.The following code example demonstrates how to create a custom HtmlTable.HtmlTableRowControlCollection that overrides the Add method so that when rows are added to a table, they are always added at the beginning of the table's row collection.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom HtmlTable - CustomHtmlTableRowControlCollection Example</title>
  </head>
  <body>
    <form id="Form1" 
          method="post" 
          runat="server">
      <h3>Custom HtmlTable - CustomHtmlTableRowControlCollection Example</h3>
      
      <aspSample:CustomHtmlTableRowControlCollection 
        id="HtmlTable1" 
        name="HtmlTable1" 
        runat="server" 
        border="1"
        cellSpacing="0" 
        cellPadding="5">
        <tr>
          <td>1,1</td>
          <td>1,2</td>
          <td>1,3</td>
        </tr>
        <tr>
          <td>2,1</td>
          <td>2,2</td>
          <td>2,3</td>
        </tr>
        <tr>
          <td>3,1</td>
          <td>3,2</td>
          <td>3,3</td>
        </tr>
      </aspSample:CustomHtmlTableRowControlCollection>

    </form>

  </body>
</html> 
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom HtmlTable - CustomHtmlTableRowControlCollection Example</title>
  </head>
  <body>
    <form id="Form1" 
          method="post" 
          runat="server">
      <h3>Custom HtmlTable - CustomHtmlTableRowControlCollection Example</h3>
      
      <aspSample:CustomHtmlTableRowControlCollection 
        id="HtmlTable1" 
        name="HtmlTable1" 
        runat="server" 
        border="1"
        cellSpacing="0" 
        cellPadding="5">
        <tr>
          <td>1,1</td>
          <td>1,2</td>
          <td>1,3</td>
        </tr>
        <tr>
          <td>2,1</td>
          <td>2,2</td>
          <td>2,3</td>
        </tr>
        <tr>
          <td>3,1</td>
          <td>3,2</td>
          <td>3,3</td>
        </tr>
      </aspSample:CustomHtmlTableRowControlCollection>

    </form>

  </body>
</html>
using System.Web;
using System.Web.UI;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class CustomHtmlTableRowControlCollection : System.Web.UI.HtmlControls.HtmlTable
    {

       protected override ControlCollection CreateControlCollection()
       {

         return new MyHtmlTableRowControlCollection(this);
       }

       protected class MyHtmlTableRowControlCollection : ControlCollection
       {

         internal MyHtmlTableRowControlCollection(Control owner) : base(owner) { }

         public override void Add(Control child)
         {

           // Always add new rows at the top of the table.
           base.AddAt(0, child);
         }
       }
    }
}
Imports System.Web
Imports System.Web.UI
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomHtmlTableRowControlCollection
        Inherits System.Web.UI.HtmlControls.HtmlTable

        Protected Overrides Function CreateControlCollection() As System.Web.UI.ControlCollection

            Return New MyHtmlTableRowControlCollection(Me)

        End Function

        Protected Class MyHtmlTableRowControlCollection
            Inherits ControlCollection

            Friend Sub New(ByVal owner As Control)

                MyBase.New(owner)

            End Sub

            Public Overrides Sub Add(ByVal child As Control)

                ' Always add new rows at the top of the table.
                MyBase.AddAt(0, child)

            End Sub

        End Class

    End Class

End Namespace

Comentários

A HtmlTable.HtmlTableRowControlCollection classe representa uma coleção de HtmlTableRow objetos para um HtmlTable controle.The HtmlTable.HtmlTableRowControlCollection class represents a collection of HtmlTableRow objects for an HtmlTable control. Os controles podem ser adicionados no final da coleção com o Add método ou em um local de índice especificado na coleção com o AddAt método.Controls can be added at the end of the collection with the Add method, or at a specified index location in the collection with the AddAt method. Somente controles do tipo HtmlTableRow podem ser adicionados à HtmlTable.HtmlTableRowControlCollection coleção.Only controls of type HtmlTableRow can be added to the HtmlTable.HtmlTableRowControlCollection collection.

Propriedades

Count

Obtém o número de controles de servidor no objeto ControlCollection para o controle de servidor ASP.NET especificado.Gets the number of server controls in the ControlCollection object for the specified ASP.NET server control.

(Herdado de ControlCollection)
IsReadOnly

Obtém um valor que indica se o objeto ControlCollection é somente leitura.Gets a value indicating whether the ControlCollection object is read-only.

(Herdado de ControlCollection)
IsSynchronized

Obtém um valor que indica se o objeto ControlCollection está sincronizado.Gets a value indicating whether the ControlCollection object is synchronized.

(Herdado de ControlCollection)
Item[Int32]

Obtém uma referência para o controle de servidor no local do índice especificado no objeto ControlCollection.Gets a reference to the server control at the specified index location in the ControlCollection object.

(Herdado de ControlCollection)
Owner

Obtém o controle de servidor ASP.NET ao qual o objeto ControlCollection pertence.Gets the ASP.NET server control to which the ControlCollection object belongs.

(Herdado de ControlCollection)
SyncRoot

Obtém um objeto que pode ser usado para sincronizar o acesso à coleção de controels.Gets an object that can be used to synchronize access to the collection of controls.

(Herdado de ControlCollection)

Métodos

Add(Control)

Adiciona o objeto Control especificado à coleção.Adds the specified Control object to the collection.

AddAt(Int32, Control)

Adiciona o objeto Control especificado à coleção.Adds the specified Control object to the collection. O novo controle é adicionado à matriz na localização do índice especificada.The new control is added to the array at the specified index location.

Clear()

Remove todos os controles do objeto ControlCollection do controle dde servidor atual.Removes all controls from the current server control's ControlCollection object.

(Herdado de ControlCollection)
Contains(Control)

Determina se o controle de servidor especificado está no objeto ControlCollection do controle de servidor pai.Determines whether the specified server control is in the parent server control's ControlCollection object.

(Herdado de ControlCollection)
CopyTo(Array, Int32)

Copia os controles filho armazenados no objeto ControlCollection para um objeto Array, começando no local do índice especificado no Array.Copies the child controls stored in the ControlCollection object to an Array object, beginning at the specified index location in the Array.

(Herdado de ControlCollection)
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetEnumerator()

Recupera um enumerador que pode iterar pelo objeto ControlCollection.Retrieves an enumerator that can iterate through the ControlCollection object.

(Herdado de ControlCollection)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
IndexOf(Control)

Recupera o índice de um objeto Control especificado na coleção.Retrieves the index of a specified Control object in the collection.

(Herdado de ControlCollection)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
Remove(Control)

Remove o servidor especificado do objeto ControlCollection do controle de servidor pai.Removes the specified server control from the parent server control's ControlCollection object.

(Herdado de ControlCollection)
RemoveAt(Int32)

Remove um controle filho, no local do índice especificado, do objeto ControlCollection.Removes a child control, at the specified index location, from the ControlCollection object.

(Herdado de ControlCollection)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Métodos de Extensão

Cast<TResult>(IEnumerable)

Converte os elementos de um IEnumerable para o tipo especificado.Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filtra os elementos de um IEnumerable com base em um tipo especificado.Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Habilita a paralelização de uma consulta.Enables parallelization of a query.

AsQueryable(IEnumerable)

Converte um IEnumerable em um IQueryable.Converts an IEnumerable to an IQueryable.

Aplica-se a

Confira também