HtmlTable.HtmlTableRowControlCollection Classe

Définition

Représente une collection d'objets HtmlTableRow qui sont les lignes d'un contrôle HtmlTable.

protected: ref class HtmlTable::HtmlTableRowControlCollection : System::Web::UI::ControlCollection
protected class HtmlTable.HtmlTableRowControlCollection : System.Web.UI.ControlCollection
Protected Class HtmlTable.HtmlTableRowControlCollection
Inherits ControlCollection
Héritage
HtmlTable.HtmlTableRowControlCollection

Exemples

L’exemple de code suivant montre comment créer une méthode personnalisée HtmlTable.HtmlTableRowControlCollection qui remplace la Add méthode afin que lorsque les lignes soient ajoutées à une table, elles sont toujours ajoutées au début de la collection de lignes de la table.

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

Remarques

La HtmlTable.HtmlTableRowControlCollection classe représente une collection d’objets HtmlTableRow pour un HtmlTable contrôle. Les contrôles peuvent être ajoutés à la fin de la collection avec la Add méthode, ou à un emplacement d’index spécifié dans la collection avec la AddAt méthode. Seuls les contrôles de type HtmlTableRow peuvent être ajoutés à la HtmlTable.HtmlTableRowControlCollection collection.

Propriétés

Count

Obtient le nombre de contrôles serveur dans l'objet ControlCollection pour le contrôle serveur ASP.NET spécifié.

(Hérité de ControlCollection)
IsReadOnly

Obtient une valeur indiquant si l’objet ControlCollection est en lecture seule.

(Hérité de ControlCollection)
IsSynchronized

Obtient une valeur indiquant si l'objet ControlCollection est synchronisé.

(Hérité de ControlCollection)
Item[Int32]

Obtient une référence au contrôle serveur à l'emplacement d'index spécifié dans l'objet ControlCollection.

(Hérité de ControlCollection)
Owner

Obtient le contrôle serveur ASP.NET auquel l'objet ControlCollection appartient.

(Hérité de ControlCollection)
SyncRoot

Obtient un objet qui peut être utilisé pour synchroniser l'accès à la collection de contrôles.

(Hérité de ControlCollection)

Méthodes

Add(Control)

Ajoute l'objet Control spécifié à la collection.

AddAt(Int32, Control)

Ajoute l'objet Control spécifié à la collection. Le nouveau contrôle est ajouté au tableau à l'emplacement d'index spécifié.

Clear()

Supprime tous les contrôles de l'objet ControlCollection du contrôle serveur en cours.

(Hérité de ControlCollection)
Contains(Control)

Détermine si le contrôle serveur spécifié se trouve dans l'objet ControlCollection du contrôle serveur parent.

(Hérité de ControlCollection)
CopyTo(Array, Int32)

Copie les contrôles enfants stockés dans l'objet ControlCollection vers un objet Array, en commençant à l'emplacement d'index spécifié dans Array.

(Hérité de ControlCollection)
Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
GetEnumerator()

Récupère un énumérateur qui peut effectuer une itération au sein de l'objet ControlCollection.

(Hérité de ControlCollection)
GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
IndexOf(Control)

Récupère l'index d'un objet Control spécifié dans la collection.

(Hérité de ControlCollection)
MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
Remove(Control)

Supprime le contrôle serveur spécifié de l'objet ControlCollection du contrôle serveur parent.

(Hérité de ControlCollection)
RemoveAt(Int32)

Supprime un contrôle enfant de l'objet ControlCollection, à l'emplacement d'index spécifié.

(Hérité de ControlCollection)
ToString()

Retourne une chaîne qui représente l'objet actuel.

(Hérité de Object)

Méthodes d’extension

Cast<TResult>(IEnumerable)

Effectue un cast des éléments d'un IEnumerable vers le type spécifié.

OfType<TResult>(IEnumerable)

Filtre les éléments d'un IEnumerable en fonction du type spécifié.

AsParallel(IEnumerable)

Active la parallélisation d'une requête.

AsQueryable(IEnumerable)

Convertit un IEnumerable en IQueryable.

S’applique à

Voir aussi