PanelStyle.HorizontalAlign 屬性

定義

取得或設定在面板控制項中內容的水平對齊。

public:
 virtual property System::Web::UI::WebControls::HorizontalAlign HorizontalAlign { System::Web::UI::WebControls::HorizontalAlign get(); void set(System::Web::UI::WebControls::HorizontalAlign value); };
public virtual System.Web.UI.WebControls.HorizontalAlign HorizontalAlign { get; set; }
member this.HorizontalAlign : System.Web.UI.WebControls.HorizontalAlign with get, set
Public Overridable Property HorizontalAlign As HorizontalAlign

屬性值

HorizontalAlign

其中一個 HorizontalAlign 值。 預設為 NotSet

例外狀況

水平對齊不是其中一個 HorizontalAlign 值。

範例

下列程式碼範例會將 HorizontalAlign 兩個面板控制項 Panel1Panel2 的屬性設定為 HorizontalAlign.Center 列舉值。 如需可用來執行範例的 .aspx 檔案,請參閱 PanelStyle 主題。

public partial class PanelStylecs_aspx : Page
{
    void Page_Load(object sender, EventArgs e)
    {
        StateBag panelState = new StateBag();
        PanelStyle myPanelStyle = new PanelStyle(panelState);
        
        // Set the properties of the PanelStyle class.
        myPanelStyle.HorizontalAlign = HorizontalAlign.Center;
        myPanelStyle.ScrollBars = ScrollBars.Both;
        myPanelStyle.Wrap = false;
        myPanelStyle.Direction = ContentDirection.LeftToRight;
        myPanelStyle.BackImageUrl = @"~\images\picture.jpg";

        // Use the ApplyStyle method of the Panel control to apply
        // the settings from the myPanelStyle object.
        Panel1.ApplyStyle(myPanelStyle);
        Panel2.ApplyStyle(myPanelStyle); 
    }
}
Partial Class PanelStylevb_aspx
    Inherits Page

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim panelState As StateBag = New StateBag()
        Dim myPanelStyle As PanelStyle = New PanelStyle(panelState)

        ' Set the properties of the PanelStyle class.
        myPanelStyle.HorizontalAlign = HorizontalAlign.Center
        myPanelStyle.ScrollBars = ScrollBars.Both
        myPanelStyle.Wrap = False
        myPanelStyle.Direction = ContentDirection.LeftToRight
        myPanelStyle.BackImageUrl = "~\images\picture.jpg"

        ' Use the ApplyStyle method of the Panel control to apply
        ' the settings from the myPanelStyle object.
        Panel1.ApplyStyle(myPanelStyle)
        Panel2.ApplyStyle(myPanelStyle)
        
    End Sub

End Class

備註

屬性 HorizontalAlign 會指定面板控制項中內容的水準對齊方式。

屬性 HorizontalAlign 是使用其中 HorizontalAlign 一個列舉值來設定。 下表列出可能的值。

描述
NotSet 水平對齊未設定。
Left 面板的內容靠左對齊。
Center 面板的內容會置中。
Right 面板的內容靠右對齊。

注意

. HorizontalAlign如果 屬性設定為 NotSet ,但 屬性是在包含面板控制項的控制項中設定,則設定會繼承自包含控制項。

適用於

另請參閱