Bagikan melalui


PanelStyle.HorizontalAlign Properti

Definisi

Mendapatkan atau mengatur perataan horizontal konten dalam kontrol panel.

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

Nilai Properti

Salah HorizontalAlign satu nilai. Defaultnya adalah NotSet.

Pengecualian

Perataan horizontal bukan salah HorizontalAlign satu nilai.

Contoh

Contoh kode berikut mengatur HorizontalAlign properti dua kontrol panel, Panel1 dan Panel2, ke HorizontalAlign.Center nilai enumerasi. Untuk file .aspx yang dapat digunakan untuk menjalankan contoh, lihat topiknya 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

Keterangan

Properti HorizontalAlign menentukan perataan horizontal konten dalam kontrol panel.

Properti HorizontalAlign diatur menggunakan salah HorizontalAlign satu nilai enumerasi. Tabel berikut ini mencantumkan nilai yang mungkin.

Nilai Deskripsi
NotSet Perataan horizontal tidak diatur.
Left Isi panel diratakan kiri.
Center Isi panel dipusatkan.
Right Isi panel selaras dengan kanan.

Nota

. HorizontalAlign Jika properti diatur ke NotSet tetapi properti diatur dalam kontrol yang berisi kontrol panel, pengaturan diwarisi dari kontrol yang berisi.

Berlaku untuk

Lihat juga