PanelStyle.HorizontalAlign 属性

定义

获取或设置面板控件中内容的水平对齐方式。Gets or sets the horizontal alignment of the contents within a panel control.

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 值之一。One of the HorizontalAlign values. 默认值为 NotSetThe default is NotSet.

例外

水平对齐方式不是 HorizontalAlign 值之一。The horizontal alignment is not one of the HorizontalAlign values.

示例

下面的代码示例将 HorizontalAlign 两个 panel 控件的属性 Panel1 和设置 Panel2HorizontalAlign.Center 枚举值。The following code example sets the HorizontalAlign properties of two panel controls, Panel1 and Panel2, to the HorizontalAlign.Center enumeration value. 有关可用于运行示例的 .aspx 文件,请参阅 PanelStyle 主题。For an .aspx file that can be used to run the example, see the PanelStyle topic.

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属性指定 panel 控件内内容的水平对齐方式。The HorizontalAlign property specifies the horizontal alignment of the contents within a panel control.

HorizontalAlign使用枚举值之一设置属性 HorizontalAlignThe HorizontalAlign property is set using one of the HorizontalAlign enumeration values. 下表列出了可能的值。The following table lists the possible values.

Value 说明Description
NotSet 未设置水平对齐方式。The horizontal alignment is not set.
Left 面板的内容处于左对齐。The contents of the panel are left-aligned.
Center 面板的内容处于中心位置。The contents of the panel are centered.
Right 面板的内容是右对齐的。The contents of the panel are right-aligned.

备注

.. 如果将 HorizontalAlign 属性设置为, NotSet 但属性是在包含 panel 控件的控件中设置的,则会从包含控件继承设置。If the HorizontalAlign property is set to NotSet but the property is set in the control that contains the panel control, the setting is inherited from the containing control.

适用于

另请参阅