This documentation is archived and is not being maintained.

Table.HorizontalAlign Property

Gets or sets the horizontal alignment of the Table control on the page.

[Visual Basic]
Public Overridable Property HorizontalAlign As HorizontalAlign
[C#]
public virtual HorizontalAlign HorizontalAlign {get; set;}
[C++]
public: __property virtual HorizontalAlign get_HorizontalAlign();
public: __property virtual void set_HorizontalAlign(HorizontalAlign);
[JScript]
public function get HorizontalAlign() : HorizontalAlign;
public function set HorizontalAlign(HorizontalAlign);

Property Value

One of the HorizontalAlign enumeration values. The default value is NotSet.

Remarks

Use the HorizontalAlign property to specify the horizontal alignment of the Table control within the page. The following table lists the different horizontal alignment styles.

HorizontalAlign value Description
NotSet The horizontal alignment of the Table control has not been set.
Left The Table control is left justified on the page.
Center The Table control is centered on the page.
Right The Table control is right justified on the page.
Justify The Table control is aligned with both the left and right margins of the page.

Example

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Table - VB.NET Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Table - VB.NET Example</h3>

            <asp:Table id="Table1" runat="server" GridLines="Both"
             BackImageUrl="image1.gif" HorizontalAlign="Center"
             CellSpacing="3" CellPadding="3">
               <asp:TableRow>
                    <asp:TableCell>Row 0, Col 0</asp:TableCell>
                    <asp:TableCell>Row 0, Col 1</asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>Row 1, Col 0</asp:TableCell>
                    <asp:TableCell>Row 1, Col 1</asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        </form>
    </body>
</HTML>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Table - C# Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Table - C# Example</h3>

            <asp:Table 
              id="Table1" 
              runat="server" 
              GridLines="Both"
              BackImageUrl="image1.gif" 
              HorizontalAlign="Center"
              CellSpacing="3" 
              CellPadding="3">
        <asp:TableRow>
          <asp:TableCell>Row 0, Col 0</asp:TableCell>
          <asp:TableCell>Row 0, Col 1</asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
          <asp:TableCell>Row 1, Col 0</asp:TableCell>
          <asp:TableCell>Row 1, Col 1</asp:TableCell>
        </asp:TableRow>
      </asp:Table>
      
      </form>
    </body>
</HTML>

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Table Class | Table Members | System.Web.UI.WebControls Namespace | HorizontalAlign

Show: