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 两个面板控件 Panel1 Panel2的属性设置为 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 但属性在包含面板控件的控件中设置,则设置继承自包含控件。

适用于

另请参阅