Panel.HorizontalAlign 속성

정의

패널 내에 있는 내용의 가로 맞춤을 가져오거나 설정합니다.

public:
 virtual property System::Web::UI::WebControls::HorizontalAlign HorizontalAlign { System::Web::UI::WebControls::HorizontalAlign get(); void set(System::Web::UI::WebControls::HorizontalAlign value); };
[System.ComponentModel.Bindable(true)]
public virtual System.Web.UI.WebControls.HorizontalAlign HorizontalAlign { get; set; }
public virtual System.Web.UI.WebControls.HorizontalAlign HorizontalAlign { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.HorizontalAlign : System.Web.UI.WebControls.HorizontalAlign with get, set
member this.HorizontalAlign : System.Web.UI.WebControls.HorizontalAlign with get, set
Public Overridable Property HorizontalAlign As HorizontalAlign

속성 값

HorizontalAlign

HorizontalAlign 값 중 하나입니다. 기본값은 NotSet입니다.

특성

예외

가로 맞춤이 HorizontalAlign 값이 아닌 경우

예제

다음 예제에서는 컨트롤을 Panel오른쪽 맞춤 또는 왼쪽에 맞추는 방법을 보여 줍니다.

참고

다음 코드 샘플 단일 파일 코드 모델을 사용 하 고 코드 숨김 파일에 직접 복사 하는 경우 제대로 작동 하지 않을 수 있습니다. 이 코드 샘플.aspx 확장명이 있는 빈 텍스트 파일에 복사 해야 합니다. Web Forms 코드 모델에 대 한 자세한 내용은 참조 하세요. ASP.NET Web Forms 페이지 코드 모델합니다.

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>Panel Example</title>
<script language="C#" runat="server">
 
    void Page_Load(Object sender, EventArgs e) {
       Label l = new Label();
       l.Text = "This panel contains a label control.";
       Panel1.Controls.Add(l);
    }
     
    void Button1_Click(Object sender, EventArgs e) {
       if (Panel1.HorizontalAlign == HorizontalAlign.Left) {
          Panel1.HorizontalAlign = HorizontalAlign.Right;
          Button1.Text = "Left justify text within Panel";
       } 
       else {
          Panel1.HorizontalAlign = HorizontalAlign.Left;
          Button1.Text = "Right justify text within Panel";
       }
    }
    </script>
 
 </head>
 <body>
    <h3>Panel Example</h3>
    <form id="form1" runat="server">
 
       <asp:Panel id="Panel1" Height="200" Width="100" BackColor="Gainsboro"
            Wrap="True" HorizontalAlign="Right" runat="server"/>
 
       <br />
       <asp:Button id="Button1" OnClick="Button1_Click"
            Text="Left justify text within panel" runat="server"/>
 
    </form>
 </body>
 </html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>Panel Example</title>
<script language="VB" runat="server">
 
    Sub Page_Load(sender As Object, e As EventArgs)
       Dim l As New Label()
       l.Text = "This panel contains a label control."
       Panel1.Controls.Add(l)
    End Sub
     
    Sub Button1_Click(sender As Object, e As EventArgs)
       If Panel1.HorizontalAlign = HorizontalAlign.Left Then
          Panel1.HorizontalAlign = HorizontalAlign.Right
          Button1.Text = "Left justify text within Panel"
       Else
          Panel1.HorizontalAlign = HorizontalAlign.Left
          Button1.Text = "Right justify text within Panel"
       End If
    End Sub
    
    </script>
 
 </head>
 <body>
    <h3>Panel Example</h3>
    <form id="form1" runat="server">
 
       <asp:Panel id="Panel1" Height="200" Width="100" BackColor="Gainsboro"
            Wrap="True" HorizontalAlign="Right" runat="server"/>
 
       <br />
       <asp:Button id="Button1" OnClick="Button1_Click"
            Text="Left justify text within panel" runat="server"/>
 
    </form>
 </body>
 </html>

설명

이 속성을 사용하여 에 있는 요소의 맞춤을 지정할 수 Panel있습니다.

적용 대상

추가 정보