Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
TableCellCollection, classe
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
TableCellCollection Class

Encapsulates a collection of TableHeaderCell and TableCell objects that make up a row in a Table control. This class cannot be inherited.

System..::.Object
  System.Web.UI.WebControls..::.TableCellCollection

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic
Public NotInheritable Class TableCellCollection _
    Implements IList, ICollection, IEnumerable
C#
public sealed class TableCellCollection : IList, 
    ICollection, IEnumerable
Visual C++
public ref class TableCellCollection sealed : IList, 
    ICollection, IEnumerable
F#
[<Sealed>]
type TableCellCollection =  
    class
        interface IList
        interface ICollection
        interface IEnumerable
    end

The TableCellCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of TableCell objects in the TableCellCollection.
Public propertyIsReadOnlyGets a value indicating whether the TableCellCollection is read-only.
Public propertyIsSynchronizedGets a value indicating whether access to the TableCellCollection is synchronized (thread-safe).
Public propertyItemGets a TableCell from the TableCellCollection at the specified index.
Public propertySyncRootGets the object that can be used to synchronize access to the TableCellCollection.
Top
  NameDescription
Public methodAddAppends the specified TableCell to the end of the TableCellCollection.
Public methodAddAtAdds the specified TableCell to the TableCellCollection at the specified index location.
Public methodAddRangeAppends the TableCell objects from the specified array to the end of the collection.
Public methodClearRemoves all TableCell objects from the TableCellCollection.
Public methodCopyToCopies the items from the TableCellCollection to the specified System..::.Array, starting with the specified index in the System..::.Array.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetCellIndexReturns a value that represents the index of the specified TableCell from the TableCellCollection.
Public methodGetEnumeratorReturns a System.Collections..::.IEnumerator implemented object that contains all TableCell objects in the TableCellCollection.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the specified TableCell from the TableCellCollection.
Public methodRemoveAtRemoves a TableCell from the TableCellCollection at the specified index.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast<(Of <(TResult>)>)Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType<(Of <(TResult>)>)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
  NameDescription
Explicit interface implemetationPrivate methodIList..::.AddInfrastructure. Adds an object to the collection.
Explicit interface implemetationPrivate methodIList..::.ContainsInfrastructure. Determines whether the specified object is contained within the collection.
Explicit interface implemetationPrivate methodIList..::.IndexOfInfrastructure. Searches for the specified object and returns the zero-based index of the first occurrence within the collection.
Explicit interface implemetationPrivate methodIList..::.InsertInfrastructure. Inserts an object into the collection at the specified index.
Explicit interface implemetationPrivate propertyIList..::.IsFixedSizeInfrastructure. For a description of this member, see IsFixedSize.
Explicit interface implemetationPrivate propertyIList..::.ItemInfrastructure. For a description of this member, see Item.
Explicit interface implemetationPrivate methodIList..::.RemoveInfrastructure. Removes an object from the collection.
Top

Use this class to programmatically manage a collection of TableCell objects that make up a row in a Table control. This class is commonly used to add or remove cells from a row in a Table control.

NoteNote

A Table control contains a Rows collection that represents a collection of TableRow objects. Each TableRow represents an individual row in the table and contains a Cells collection that represents a collection of TableCell objects. These TableCell objects represent the individual cells in the table. To get an individual cell, you must first get a TableRow from the Rows collection of a Table control. You can then get a TableCell from the Cells collection of the TableRow.

The following example demonstrates how to programmatically fill a Table control. TableCell objects, which represent individual cells, are added to TableRow objects, which represent the individual rows, through the Cells property.

Visual Basic
<%@ 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">

    Private Sub Page_Load(sender As Object, e As EventArgs)
        ' Generate rows and cells.           
        Dim numrows As Integer = 4
        Dim numcells As Integer = 6
        Dim counter As Integer = 1
        Dim rowNum As Integer
        Dim cellNum As Integer
        For rowNum = 0 To numrows - 1
            Dim rw As New TableRow()
            For cellNum = 0 To numcells - 1
                Dim cel As New TableCell()
                cel.Text = counter.ToString()
                counter += 1
                rw.Cells.Add(cel)
            Next
            Table1.Rows.Add(rw)
        Next
    End Sub

    Private Sub Button_Click_Coord(sender As Object, e As EventArgs)            
        Dim rowNum As Integer
        Dim cellNum As Integer
        Dim rowCount As Integer
        For rowCount = 0 To Table1.Rows.Count - 1
            For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1                    
                Table1.Rows(rowNum).Cells(cellNum).Text = _
                    String.Format("(Row{0}, Cell{1})", rowNum, cellNum)
            Next
        Next
    End Sub

    Private Sub Button_Click_Number(sender As Object, e As EventArgs)
        Dim counter As Integer = 1

        Dim rowNum As Integer
        Dim cellNum As Integer
        For rowNum = 0 To Table1.Rows.Count - 1
            For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1                    
                Table1.Rows(rowNum).Cells(cellNum).Text = _
                    counter.ToString()
                counter += 1
            Next 
        Next
    End Sub

</script>

<html  >
<head runat="server">
    <title>TableCellCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>TableCellCollection Example</h3>
       <asp:Table id="Table1" 
            runat="server"/>
       <br />
       <center>
          <asp:Button id="Button1"
               Text="Display Table Coordinates"
               OnClick="Button_Click_Coord"
               runat="server"/>
          <asp:Button id="Button2"
               Text="Display Cell Numbers"
               OnClick="Button_Click_Number"
               runat="server"/>
       </center>

    </div>
    </form>
</body>
</html>
C#
<%@ 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">

    private void Page_Load(Object sender, EventArgs e) 
    {
        // Generate rows and cells.           
        int numrows = 4;
        int numcells = 6;
        int counter = 1;
        for (int rowNum = 0; rowNum < numrows; rowNum++) 
        {          
            TableRow rw = new TableRow();
            for (int cellNum = 0; cellNum < numcells; cellNum++) 
            {
                TableCell cel = new TableCell();
                cel.Text=counter.ToString();
                counter++;
                rw.Cells.Add(cel);
            }
            Table1.Rows.Add(rw);
        }
    }

    private void Button_Click_Coord(object sender, EventArgs e) 
    {
        for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++) 
        {          
            for (int cellNum = 0; cellNum < 
                Table1.Rows[rowNum].Cells.Count; cellNum++) 
            {
                Table1.Rows[rowNum].Cells[cellNum].Text = 
                    String.Format("(Row{0}, Cell{1})", rowNum, cellNum);
            }
        }
    }

    private void Button_Click_Number(object sender, EventArgs e) 
    {
        int counter = 1;

        for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++) 
        {
            for (int cellNum = 0; cellNum < 
                Table1.Rows[rowNum].Cells.Count; cellNum++) 
            {
                Table1.Rows[rowNum].Cells[cellNum].Text = 
                    counter.ToString();
                counter++;
            }            
        }
    }

</script>

<html  >
<head runat="server">
    <title>TableCellCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>TableCellCollection Example</h3>
       <asp:Table id="Table1" 
            runat="server"/>
       <br />
       <center>
          <asp:Button id="Button1"
               Text="Display Table Coordinates"
               OnClick="Button_Click_Coord"
               runat="server"/>
          <asp:Button id="Button2"
               Text="Display Cell Numbers"
               OnClick="Button_Click_Number"
               runat="server"/>
       </center>

    </div>
    </form>
</body>
</html>

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Bibliothèque de classes .NET Framework
TableCellCollection, classe

Encapsule une collection d'objets TableHeaderCell et TableCell formant une ligne dans un contrôle Table. Cette classe ne peut pas être héritée.

System..::.Object
  System.Web.UI.WebControls..::.TableCellCollection

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web (dans System.Web.dll)
Visual Basic
Public NotInheritable Class TableCellCollection _
    Implements IList, ICollection, IEnumerable
C#
public sealed class TableCellCollection : IList, 
    ICollection, IEnumerable
VisualC++
public ref class TableCellCollection sealed : IList, 
    ICollection, IEnumerable
F#
[<Sealed>]
type TableCellCollection =  
    class
        interface IList
        interface ICollection
        interface IEnumerable
    end

Le type TableCellCollection expose les membres suivants.

  NomDescription
Propriété publiqueCountObtient le nombre d'objets TableCell de la classe TableCellCollection.
Propriété publiqueIsReadOnlyObtient une valeur indiquant si TableCellCollection est en lecture seule.
Propriété publiqueIsSynchronizedObtient une valeur indiquant si l'accès à TableCellCollection est synchronisé (thread-safe).
Propriété publiqueItemObtient un objet TableCell à partir du TableCellCollection à l'index spécifié.
Propriété publiqueSyncRootObtient l'objet pouvant permettre de synchroniser l'accès à TableCellCollection.
Début
  NomDescription
Méthode publiqueAddAjoute le TableCell spécifié à la fin de TableCellCollection.
Méthode publiqueAddAtAjoute le TableCell spécifié à TableCellCollection à l'emplacement d'index spécifié.
Méthode publiqueAddRangeAjoute les objets TableCell du tableau spécifié à la fin de la collection.
Méthode publiqueClearSupprime tous les objets TableCell de la TableCellCollection.
Méthode publiqueCopyToCopie les éléments de TableCellCollection dans le System..::.Array spécifié, à commencer par l'index spécifié dans System..::.Array.
Méthode publiqueEquals(Object)Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.)
Méthode protégéeFinalizeAutorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.)
Méthode publiqueGetCellIndexRetourne une valeur représentant l'index du TableCell spécifié à partir de TableCellCollection.
Méthode publiqueGetEnumeratorRetourne un objet implémentant System.Collections..::.IEnumerator qui contient tous les objets TableCell dans TableCellCollection.
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode publiqueRemoveSupprime le TableCell spécifié de TableCellCollection.
Méthode publiqueRemoveAtSupprime TableCell de TableCellCollection à l'index spécifié.
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Début
  NomDescription
Méthode d'extension publiqueAsParallelActive la parallélisation d'une requête. (Défini par ParallelEnumerable.)
Méthode d'extension publiqueAsQueryableConvertit un IEnumerable en IQueryable. (Défini par Queryable.)
Méthode d'extension publiqueCast<(Of <(TResult>)>)Convertit les éléments d'un IEnumerable vers le type spécifié. (Défini par Enumerable.)
Méthode d'extension publiqueOfType<(Of <(TResult>)>)Filtre les éléments d'un IEnumerable en fonction du type spécifié. (Défini par Enumerable.)
Début
  NomDescription
Implémentation d'interface expliciteMéthode privéeIList..::.AddInfrastructure. Ajoute un objet à la collection.
Implémentation d'interface expliciteMéthode privéeIList..::.ContainsInfrastructure. Détermine si la collection contient l'objet spécifié.
Implémentation d'interface expliciteMéthode privéeIList..::.IndexOfInfrastructure. Recherche l'objet spécifié et retourne l'index de base zéro de la première occurrence de la collection.
Implémentation d'interface expliciteMéthode privéeIList..::.InsertInfrastructure. Insère un objet dans la collection à l'index spécifié.
Implémentation d'interface explicitePropriété privéeIList..::.IsFixedSizeInfrastructure. Pour obtenir une description de ce membre, consultez IsFixedSize.
Implémentation d'interface explicitePropriété privéeIList..::.ItemInfrastructure. Pour une description de ce membre, consultez Item.
Implémentation d'interface expliciteMéthode privéeIList..::.RemoveInfrastructure. Supprime un objet de la collection.
Début

Utilisez cette classe pour manager par programme une collection d'objets TableCell formant une ligne dans un contrôle Table. Cette classe est généralement utilisée pour ajouter des cellules à une ligne d'un contrôle Table ou en supprimer.

RemarqueRemarque

Un contrôle Table contient une collection Rows représentant une collection d'objets TableRow. Chaque TableRow représente une ligne individuelle dans le tableau et contient une collection Cells qui représente une collection d'objets TableCell. Ces objets TableCell représentent les cellules individuelles du tableau. Pour obtenir une cellule individuelle, commencez par obtenir un objet TableRow à partir de la collection Rows d'un contrôle Table. Vous pouvez ensuite obtenir un objet TableCell à partir de la collection Cells de l'objet TableRow.

L'exemple suivant montre comment remplir un contrôle Table par programmation. Les objets TableCell qui représentent des cellules individuelles sont ajoutés aux objets TableRow, qui représentent des lignes individuelles via la propriété Cells.

Visual Basic
<%@ 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">

    Private Sub Page_Load(sender As Object, e As EventArgs)
        ' Generate rows and cells.           
        Dim numrows As Integer = 4
        Dim numcells As Integer = 6
        Dim counter As Integer = 1
        Dim rowNum As Integer
        Dim cellNum As Integer
        For rowNum = 0 To numrows - 1
            Dim rw As New TableRow()
            For cellNum = 0 To numcells - 1
                Dim cel As New TableCell()
                cel.Text = counter.ToString()
                counter += 1
                rw.Cells.Add(cel)
            Next
            Table1.Rows.Add(rw)
        Next
    End Sub

    Private Sub Button_Click_Coord(sender As Object, e As EventArgs)            
        Dim rowNum As Integer
        Dim cellNum As Integer
        Dim rowCount As Integer
        For rowCount = 0 To Table1.Rows.Count - 1
            For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1                    
                Table1.Rows(rowNum).Cells(cellNum).Text = _
                    String.Format("(Row{0}, Cell{1})", rowNum, cellNum)
            Next
        Next
    End Sub

    Private Sub Button_Click_Number(sender As Object, e As EventArgs)
        Dim counter As Integer = 1

        Dim rowNum As Integer
        Dim cellNum As Integer
        For rowNum = 0 To Table1.Rows.Count - 1
            For cellNum = 0 To (Table1.Rows(rowNum).Cells.Count) - 1                    
                Table1.Rows(rowNum).Cells(cellNum).Text = _
                    counter.ToString()
                counter += 1
            Next 
        Next
    End Sub

</script>

<html  >
<head runat="server">
    <title>TableCellCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>TableCellCollection Example</h3>
       <asp:Table id="Table1" 
            runat="server"/>
       <br />
       <center>
          <asp:Button id="Button1"
               Text="Display Table Coordinates"
               OnClick="Button_Click_Coord"
               runat="server"/>
          <asp:Button id="Button2"
               Text="Display Cell Numbers"
               OnClick="Button_Click_Number"
               runat="server"/>
       </center>

    </div>
    </form>
</body>
</html>
C#
<%@ 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">

    private void Page_Load(Object sender, EventArgs e) 
    {
        // Generate rows and cells.           
        int numrows = 4;
        int numcells = 6;
        int counter = 1;
        for (int rowNum = 0; rowNum < numrows; rowNum++) 
        {          
            TableRow rw = new TableRow();
            for (int cellNum = 0; cellNum < numcells; cellNum++) 
            {
                TableCell cel = new TableCell();
                cel.Text=counter.ToString();
                counter++;
                rw.Cells.Add(cel);
            }
            Table1.Rows.Add(rw);
        }
    }

    private void Button_Click_Coord(object sender, EventArgs e) 
    {
        for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++) 
        {          
            for (int cellNum = 0; cellNum < 
                Table1.Rows[rowNum].Cells.Count; cellNum++) 
            {
                Table1.Rows[rowNum].Cells[cellNum].Text = 
                    String.Format("(Row{0}, Cell{1})", rowNum, cellNum);
            }
        }
    }

    private void Button_Click_Number(object sender, EventArgs e) 
    {
        int counter = 1;

        for (int rowNum = 0; rowNum < Table1.Rows.Count; rowNum++) 
        {
            for (int cellNum = 0; cellNum < 
                Table1.Rows[rowNum].Cells.Count; cellNum++) 
            {
                Table1.Rows[rowNum].Cells[cellNum].Text = 
                    counter.ToString();
                counter++;
            }            
        }
    }

</script>

<html  >
<head runat="server">
    <title>TableCellCollection Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>TableCellCollection Example</h3>
       <asp:Table id="Table1" 
            runat="server"/>
       <br />
       <center>
          <asp:Button id="Button1"
               Text="Display Table Coordinates"
               OnClick="Button_Click_Coord"
               runat="server"/>
          <asp:Button id="Button2"
               Text="Display Cell Numbers"
               OnClick="Button_Click_Number"
               runat="server"/>
       </center>

    </div>
    </form>
</body>
</html>

.NET Framework

Pris en charge dans : 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker