Bewerken

Share via


PanelStyle.HorizontalAlign Property

Definition

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

Property Value

One of the HorizontalAlign values. The default is NotSet.

Exceptions

The horizontal alignment is not one of the HorizontalAlign values.

Examples

The following code example sets the HorizontalAlign properties of two panel controls, Panel1 and Panel2, to the HorizontalAlign.Center enumeration value. 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

Remarks

The HorizontalAlign property specifies the horizontal alignment of the contents within a panel control.

The 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.

Note

. 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.

Applies to

See also