Table.HorizontalAlign 属性

定义

获取或设置 Table 控件在页面上的水平对齐方式。

public:
 virtual property System::Web::UI::WebControls::HorizontalAlign HorizontalAlign { System::Web::UI::WebControls::HorizontalAlign get(); void set(System::Web::UI::WebControls::HorizontalAlign value); };
[System.ComponentModel.Bindable(true)]
public virtual System.Web.UI.WebControls.HorizontalAlign HorizontalAlign { get; set; }
public virtual System.Web.UI.WebControls.HorizontalAlign HorizontalAlign { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.HorizontalAlign : System.Web.UI.WebControls.HorizontalAlign with get, set
member this.HorizontalAlign : System.Web.UI.WebControls.HorizontalAlign with get, set
Public Overridable Property HorizontalAlign As HorizontalAlign

属性值

HorizontalAlign 枚举值之一。 默认值是 NotSet

属性

示例

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Table - C# Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <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>
      
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Table - VB.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <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>
      
    </div>
    </form>
</body>
</html>

注解

HorizontalAlign使用 属性可指定控件在页面中的水平Table对齐方式。 下表列出了不同的水平对齐样式。

HorizontalAlign 值 说明
NotSet 控件的水平 Table 对齐方式尚未设置。
Left 控件 Table 在页面上保持左对齐。
Center 控件 Table 在页面上居中。
Right 控件 Table 在页面上右对齐。
Justify 控件 Table 与页面的左右边距对齐。

适用于

另请参阅