Ler en inglés

Compartir por


HorizontalAlign Enumeración

Definición

Especifica la alineación horizontal de los elementos de un contenedor.

C#
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.HorizontalAlignConverter))]
public enum HorizontalAlign
Herencia
HorizontalAlign
Atributos

Campos

Nombre Valor Description
Center 2

El contenido de un contenedor queda centrado.

Justify 4

El contenido de un contenedor se extiende de manera uniforme y se alinea con los márgenes izquierdo y derecho.

Left 1

El contenido de un contenedor queda alineado a la izquierda.

NotSet 0

No se ha establecido la alineación horizontal.

Right 3

El contenido de un contenedor queda alineado a la derecha.

Ejemplos

En el ejemplo siguiente se muestra cómo establecer la HorizontalAlign propiedad de un Panel control cambia la alineación horizontal del texto de un Label control contenido en el Panel control .

ASP.NET (C#)
<%@ 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>

Comentarios

La HorizontalAlign enumeración representa las opciones de alineación horizontal para los elementos de un contenedor, como .TableCell

Se aplica a

Produto Versións
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1