TableRow.CellControlCollection 类

表示作为 TableRow 控件的单元格的 TableCell 对象的集合。

**命名空间:**System.Web.UI.WebControls
**程序集:**System.Web(在 system.web.dll 中)

语法

声明
Protected Class CellControlCollection
    Inherits ControlCollection
用法
Dim instance As CellControlCollection
protected class CellControlCollection : ControlCollection
private ref class CellControlCollection : public ControlCollection
protected class CellControlCollection extends ControlCollection
protected class CellControlCollection extends ControlCollection

备注

TableRow.CellControlCollection 类表示 TableRow 控件的 TableCell 对象的集合。TableCell 对象可以通过 Add 方法添加到 TableRow.CellControlCollection 集合的末尾,或通过 AddAt 方法添加到 TableRow.CellControlCollection 中的指定索引位置。

只有 TableCell 对象可以添加到 TableRow.CellControlCollection 集合。

示例

下面的代码示例演示如何创建一个表,以编程方式将元素添加到该表,然后在网页上显示该表。注意 TableRow 控件的 Cells 属性如何表示 TableRow.CellControlCollection 集合,以及如何使用 Add 方法在行中添加单元格。

此代码示例摘自一个为 TableRow 类提供的更大的示例。

' Create more rows for the table.
Dim i As Integer
For i = 2 To 9
    Dim tempRow As New TableRow()
    Dim j As Integer
    For j = 0 To 2
        Dim tempCell As New TableCell()
        tempCell.Text = "(" & i & "," & j & ")"
        tempRow.Cells.Add(tempCell)
    Next j
    Table1.Rows.Add(tempRow)
Next i
// Create more rows for the table.
for (int i = 2; i < 10; i++)
{
    TableRow tempRow = new TableRow();
    for (int j = 0; j < 3; j++)
    {
        TableCell tempCell = new TableCell();
        tempCell.Text = "(" + i + "," + j + ")";
        tempRow.Cells.Add(tempCell);
    }
    Table1.Rows.Add(tempRow);
}

继承层次结构

System.Object
   System.Web.UI.ControlCollection
    System.Web.UI.WebControls.TableRow.CellControlCollection

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

TableRow.CellControlCollection 成员
System.Web.UI.WebControls 命名空间
TableRow.CreateControlCollection
ControlCollection