PanelStyle.HorizontalAlign Egenskap

Definition

Hämtar eller anger den vågräta justeringen av innehållet i en panelkontroll.

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

Egenskapsvärde

Ett av HorizontalAlign värdena. Standardvärdet är NotSet.

Undantag

Den vågräta justeringen HorizontalAlign är inte ett av värdena.

Exempel

I följande kodexempel anges egenskaperna för HorizontalAlign två panelkontroller Panel1 och Panel2, till HorizontalAlign.Center uppräkningsvärdet. En .aspx fil som kan användas för att köra exemplet finns i avsnittet 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

Kommentarer

Egenskapen HorizontalAlign anger den vågräta justeringen av innehållet i en panelkontroll.

Egenskapen HorizontalAlign anges med ett av uppräkningsvärdena HorizontalAlign . I följande tabell visas möjliga värden.

Value Description
NotSet Den vågräta justeringen har inte angetts.
Left Innehållet i panelen är vänsterjusterat.
Center Innehållet i panelen är centrerat.
Right Innehållet i panelen är högerjusterat.

Note

. Om egenskapen HorizontalAlign är inställd på NotSet men egenskapen anges i kontrollen som innehåller panelkontrollen ärvs inställningen från den innehållande kontrollen.

Gäller för

Se även