HorizontalAlign HorizontalAlign HorizontalAlign HorizontalAlign Enum

Definition

Gibt die horizontale Ausrichtung der Elemente in einem Container an.Specifies the horizontal alignment of items within a container.

public enum class HorizontalAlign
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.HorizontalAlignConverter))]
public enum HorizontalAlign
type HorizontalAlign = 
Public Enum HorizontalAlign
Vererbung
HorizontalAlignHorizontalAlignHorizontalAlignHorizontalAlign
Attribute

Felder

Center Center Center Center 2

Der Inhalt eines Containers ist zentriert ausgerichtet.The contents of a container are centered.

Justify Justify Justify Justify 4

Der Inhalt eines Containers ist gleichmäßig verteilt und am linken sowie am rechten Rand ausgerichtet.The contents of a container are uniformly spread out and aligned with both the left and right margins.

Left Left Left Left 1

Der Inhalt eines Containers ist linksbündig ausgerichtet.The contents of a container are left justified.

NotSet NotSet NotSet NotSet 0

Die horizontale Ausrichtung ist nicht festgelegt.The horizontal alignment is not set.

Right Right Right Right 3

Der Inhalt eines Containers ist rechtsbündig ausgerichtet.The contents of a container are right justified.

Beispiele

Das folgende Beispiel zeigt, wie das HorizontalAlign Festlegen der- Panel Eigenschaft eines-Steuer Elements die horizontale Ausrichtung Label für den Text eines Steuer Elements ändert, Panel das im-Steuerelement enthalten ist.The following example shows how setting the HorizontalAlign property of a Panel control changes the horizontal alignment for the text of a Label control that is contained by the Panel control.

<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void HorizontalAlignList_SelectedIndexChanged(object sender, EventArgs e)
  {
    switch (HorizontalAlignList.SelectedValue)
    {
      case "Left":
        Panel1.HorizontalAlign = HorizontalAlign.Left;
        break;
      case "Center":
        Panel1.HorizontalAlign = HorizontalAlign.Center;
        break;
      case "Justify":
        Panel1.HorizontalAlign = HorizontalAlign.Justify;
        break;
      default:
        Panel1.HorizontalAlign = HorizontalAlign.Right;
        break;
    }
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>HorizontalAlign Example</title> 
 </head>
 <body>
    <h3>HorizontalAlign Example</h3>
    <form id="form1" runat="server">
 
       <asp:Panel id="Panel1" Height="100" Width="200" BackColor="Gainsboro"
            Wrap="True" HorizontalAlign="Left" runat="server">
         <asp:Label ID="Label1" runat="server" Text="This panel contains a Label control.">
         </asp:Label>
       </asp:Panel>
 
       <br />
 
       <asp:Label ID="Label2" runat="server" Text="Horizontal Alignment:"></asp:Label>
       <asp:DropDownList ID="HorizontalAlignList" runat="server" AutoPostBack="True" 
         OnSelectedIndexChanged="HorizontalAlignList_SelectedIndexChanged">
         <asp:ListItem Selected="True">Left</asp:ListItem>
         <asp:ListItem>Center</asp:ListItem>
         <asp:ListItem>Right</asp:ListItem>
         <asp:ListItem>Justify</asp:ListItem>
       </asp:DropDownList>
 
    </form>
 </body>
 </html>    
<%@ Page Language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub HorizontalAlignList_SelectedIndexChanged()
    
    Select Case HorizontalAlignList.SelectedValue
      Case "Left"
        Panel1.HorizontalAlign = HorizontalAlign.Left
      Case "Center"
        Panel1.HorizontalAlign = HorizontalAlign.Center
      Case "Justify"
        Panel1.HorizontalAlign = HorizontalAlign.Justify
      Case Else
        Panel1.HorizontalAlign = HorizontalAlign.Right
    End Select
    
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>HorizontalAlign Example</title> 
 </head>
 <body>
    <h3>HorizontalAlign Example</h3>
    <form id="form1" runat="server">
 
       <asp:Panel id="Panel1" Height="100" Width="200" BackColor="Gainsboro"
            Wrap="True" HorizontalAlign="Left" runat="server">
         <asp:Label ID="Label1" runat="server" Text="This panel contains a Label control.">
         </asp:Label>
       </asp:Panel>
 
       <br />
 
       <asp:Label ID="Label2" runat="server" Text="Horizontal Alignment:"></asp:Label>
       <asp:DropDownList ID="HorizontalAlignList" runat="server" AutoPostBack="True" 
         onselectedindexchanged="HorizontalAlignList_SelectedIndexChanged">
         <asp:ListItem Selected="True">Left</asp:ListItem>
         <asp:ListItem>Center</asp:ListItem>
         <asp:ListItem>Right</asp:ListItem>
         <asp:ListItem>Justify</asp:ListItem>
       </asp:DropDownList>
 
    </form>
 </body>
 </html>    

Hinweise

Die HorizontalAlign -Enumeration stellt die horizontalen Ausrichtungsoptionen für Elemente in einem Container dar, TableCellz. b.The HorizontalAlign enumeration represents the horizontal alignment options for items within a container, such as a TableCell.

Gilt für: