This documentation is archived and is not being maintained.

TableHeaderCell Class

Represents a heading cell within a Table control.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

Public Class TableHeaderCell
	Inherits TableCell
Dim instance As TableHeaderCell

public class TableHeaderCell extends TableCell
public class TableHeaderCell extends TableCell

The TableHeaderCell class represents a heading cell in a Table control. You can use the Text property to specify or determine the contents of the heading cell.

This class allows you to control how the contents of the heading cell are displayed. The alignment of the contents in the heading cell is specified by setting the HorizontalAlign and VerticalAlign properties. You can use the Wrap property to specify whether the contents of the heading cell wrap in the cell.

You can also specify how many rows or columns in the Table control are occupied by an individual heading cell. The RowSpan and ColumnSpan properties control how may rows and columns are used, respectively.

The following example demonstrates how to declaratively program a TableHeaderCell control.

<%@ Page language="VB" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>

        <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 & ")"
                    Next j
                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
                    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()

                ' Add the header row to the table.
                Table1.Rows.AddAt(0, headerRow) 
            End Sub

        <form runat="server">
            <h1>TableCell Example</h1>
            <asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="3">
                    <asp:TableCell Text="(0,0)"></asp:TableCell>
                    <asp:TableCell Text="(0,1)"></asp:TableCell>
                    <asp:TableCell Text="(0,2)"></asp:TableCell>
                    <asp:TableCell Text="(1,0)"></asp:TableCell>
                    <asp:TableCell Text="(1,1)"></asp:TableCell>
                    <asp:TableCell Text="(1,2)"></asp:TableCell>


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0