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 會對齊頁面的左邊界和右邊界。

適用於

另請參閱