登陆  注册  搜索  帮助
  主题:1682,帖子:3356,会员:1661  新会员:callma1989
  精华区 | 推荐 | 新主题 | 新回复     
  .NET论坛_DOTBBS|Asp.Net开源论坛 _.net开源 > .NET开发交流 > .NET控件与组件开发 > Web服务器控件:TableCell控件
 DotBBS V2.1 介绍 DotBBS V2.1 下载 DotBBS使用帮助 DotBBS 10分钟入门教程
 DotBBS V2.1使用方法 DotBBS_V2.1_框架完全版 天津网站制作公司 谷哥哥经典语录网
 人气:2/1172  |<< << [1] >> >>|  (pages:1/1)   
 Web服务器控件:TableCell控件
  q001
 Label
 
 级别:幼儿园
 积分:Label 金币:Label
 主题:184 帖子:184
 注册:Label
 加为好友发送私信
 编辑 删除 推荐 举报 打印 收藏到IE 收藏 复制 经典搞笑语句大全

定义和用法
TableCell 控件与 Table 控件和 TableRow 控件结合,用于创建表格中的单元。

提示:每行的单元均存储在 TableRow 控件的 Cells 集合中。

属性
属性 描述 .NET
AssociatedHeaderCellID 与 TableCell 控件关联的表标题单元格列表。 2.0
ColumnSpan 单元格跨越的列数。 1.0
HorizontalAlign 单元格中内容的水平对齐方式。 1.0
RowSpan 单元格跨越的行数。 1.0
runat 规定该控件是服务器控件。必须设置为 "server"。 1.0
Text 规定单元格的文本内容。 1.0
VerticalAlign 单元格中内容的垂直对齐方式。 1.0
Wrap 规定单元格内容是否换行。 1.0

Web 控件标准属性
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth,
CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled,
SkinID, Style, TabIndex, ToolTip, Width控件标准属性
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls,
EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site,
TemplateControl, TemplateSourceDirectory, UniqueID, Visible语法
<asp:TableCell
    AccessKey="string"
    AssociatedHeaderCellID="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
    BorderWidth="size"
    ColumnSpan="integer"
    CssClass="string"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
        Large|X-Large|XX-Large"
    Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    HorizontalAlign="NotSet|Left|Center|Right|Justify"
    ID="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    RowSpan="integer"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    Text="string"
    ToolTip="string"
    VerticalAlign="NotSet|Top|Middle|Bottom"
    Visible="True|False"
    Width="size"
    Wrap="True|False"
/></asp:TableCell>

备注:TableCell 类的一个实例表示 Table 控件中的一个单元格。每一行的单元格都存储在表示该行的 TableRow 的 Cells 集合中。使用 Text 属性可操作单元格的内容。

此类使您可以控制单元格内容的显示方式。设置 HorizontalAlign 和 VerticalAlign 属性可以分别指定单元格内容的水平和垂直对齐方式。可使用 Wrap 属性指定当到达单元格的结尾时单元格内容是否自动在下一行继续。

还可指定单元格在 Table 控件中占用的行数或列数。RowSpan 和 ColumnSpan 属性分别控制所用的行数和列数。

警告:文本在 TableCell 控件中显示之前并非 HTML 编码形式。这使得可以在文本中的 HTML 标记中嵌入脚本。如果控件的值是由用户输入的,请务必要对输入值进行验证以防止出现安全漏洞。

实例
下面的代码示例演示如何创建一个表、以编程方式向表中添加元素并在网页上显示该表。注意 TableCell 控件是如何实例化的,以及如何设置它们的属性值。

Visual Basic

<%@ Page language="VB" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<html>
    <head>
        <script runat="server">
            Private Sub Page_Load(sender As Object, e As System.EventArgs)
                ' Create a TableItemStyle object that can be
                ' set as the default style for all cells
                ' in the table.
                Dim tableStyle As New TableItemStyle()
                tableStyle.HorizontalAlign = HorizontalAlign.Center
                tableStyle.VerticalAlign = VerticalAlign.Middle
                tableStyle.Width = Unit.Pixel(100)
                ' 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
                ' Apply the TableItemStyle to all rows in the table.
                Dim r As TableRow
                For Each r In  Table1.Rows
                    Dim c As TableCell
                    For Each c In  r.Cells
                        c.ApplyStyle(tableStyle)
                    Next c
                Next r
                ' Create a header for the table.
                Dim header As New TableHeaderCell()
                header.RowSpan = 1
                header.ColumnSpan = 3
                header.Text = "Table of (x,y) Values"
                header.Font.Bold = true
                header.BackColor = Color.Gray
                header.HorizontalAlign = HorizontalAlign.Center
                header.VerticalAlign = VerticalAlign.Middle
                ' Add the header to a new row.
                Dim headerRow As New TableRow()
                headerRow.Cells.Add(header)
                ' Add the header row to the table.
                Table1.Rows.AddAt(0, headerRow)
            End Sub
        </script>
    </head>
    <body>
        <form runat="server">
            <h1>TableCell Example</h1>
            <asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="3">
                <asp:TableRow>
                    <asp:TableCell Text="(0,0)"></asp:TableCell>
                    <asp:TableCell Text="(0,1)"></asp:TableCell>
                    <asp:TableCell Text="(0,2)"></asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Text="(1,0)"></asp:TableCell>
                    <asp:TableCell Text="(1,1)"></asp:TableCell>
                    <asp:TableCell Text="(1,2)"></asp:TableCell>
                </asp:TableRow>
            </asp:table>
        </form>
    </body>
</html>

C#

<%@ Page language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<html>
    <head>
        <script runat="server">
            private void Page_Load(object sender, System.EventArgs e)
            {
                // Create a TableItemStyle object that can be
                // set as the default style for all cells
                // in the table.
                TableItemStyle tableStyle = new TableItemStyle();
                tableStyle.HorizontalAlign = HorizontalAlign.Center;
                tableStyle.VerticalAlign = VerticalAlign.Middle;
                tableStyle.Width = Unit.Pixel(100);
                // 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);
                }
                // Apply the TableItemStyle to all rows in the table.
                foreach (TableRow r in Table1.Rows)
                    foreach (TableCell c in r.Cells)
                        c.ApplyStyle(tableStyle);
                // Create a header for the table.
                TableHeaderCell header = new TableHeaderCell();
                header.RowSpan = 1;
                header.ColumnSpan = 3;
                header.Text = "Table of (x,y) Values";
                header.Font.Bold = true;
                header.BackColor = Color.Gray;
                header.HorizontalAlign = HorizontalAlign.Center;
                header.VerticalAlign = VerticalAlign.Middle;
                // Add the header to a new row.
                TableRow headerRow = new TableRow();
                headerRow.Cells.Add(header);
                // Add the header row to the table.
                Table1.Rows.AddAt(0, headerRow); 
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <h1>TableCell Example</h1>
            <asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="3">
                <asp:TableRow>
                    <asp:TableCell Text="(0,0)"></asp:TableCell>
                    <asp:TableCell Text="(0,1)"></asp:TableCell>
                    <asp:TableCell Text="(0,2)"></asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Text="(1,0)"></asp:TableCell>
                    <asp:TableCell Text="(1,1)"></asp:TableCell>
                    <asp:TableCell Text="(1,2)"></asp:TableCell>
                </asp:TableRow>
            </asp:table>
        </form>
    </body>
</html>

Label
  posted:2009-3-27 21:08:00 | [楼 主]
  meng666666
 
 
 级别:幼儿园
 积分:6 金币:0
 主题:0 帖子:1
 注册:2010-03-08
 加为好友发送私信
 编辑  删除       经典搞笑语句大全
  posted:2010-3-8 10:56:00 | [1  楼]
  ycysyhj
 
 
 级别:小学一年级
 积分:22 金币:8
 主题:0 帖子:9
 注册:2010-06-19
 加为好友发送私信
 编辑  删除       经典搞笑语句大全
----------引用 @ meng666666----------
 
-------------------------------
  posted:2010-9-8 9:15:00 | [2  楼]
 人气:2/1172  |<< << [1] >> >>|  (pages:1/1)   
  << 上一篇 Web服务器控件:TableRow控件
  >> 下一篇 [公告]中秋佳节 时代主机低至7折优惠
    Re:Web服务器控件:TableCell控件
选项
HTML可用
帐号: 密码: 没帐号,请注册

附  件:
验证码:
小提示:按Ctrl+Enter直接提交
 




Powered By DotBBS V2.0 Sql Server SP1   Copyright © 2010 .NET论坛_DOTBBS|Asp.Net开源论坛 _.net开源    返回顶部     清除缓存