.NET Framework Class Library HorizontalAlign Enumeration Specifies the horizontal alignment of items within a container.
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web (in System.Web.dll)

Syntax
Public Enumeration HorizontalAlign
public enum HorizontalAlign
public enum class HorizontalAlign

Members
| Member name | Description |
|---|
| NotSet | The horizontal alignment is not set. | | Left | The contents of a container are left justified. | | Center | The contents of a container are centered. | | Right | The contents of a container are right justified. | | Justify | The contents of a container are uniformly spread out and aligned with both the left and right margins. |

Remarks
The HorizontalAlign enumeration represents the horizontal alignment options for items within a container, such as a TableCell.

Examples
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="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 >
<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="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 >
<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>

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Bibliothèque de classes .NET Framework HorizontalAlign, énumération Spécifie l'alignement horizontal des éléments figurant dans un conteneur.
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
Public Enumeration HorizontalAlign
public enum HorizontalAlign
public enum class HorizontalAlign

Membres
| Nom de membre | Description |
|---|
| NotSet | L'alignement horizontal n'est pas défini. | | Left | Le contenu d'un conteneur est aligné à gauche. | | Center | Le contenu d'un conteneur est centré. | | Right | Le contenu d'un conteneur est aligné à droite. | | Justify | Le contenu d'un conteneur est réparti uniformément et aligné avec les marges gauches et droites. |

Notes
L'énumération HorizontalAlign représente les options d'alignement horizontal pour les éléments figurant dans un conteneur, tel que TableCell.

Exemples
L'exemple suivant montre comment la définition de la propriété HorizontalAlign d'un contrôle Panel modifie l'alignement horizontal du texte d'un contrôle Label contenu dans le contrôle Panel.
<%@ 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 >
<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="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 >
<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>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0, 1.1, 1.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Voir aussi
|