GridView.HorizontalAlign Propriété

Définition

Obtient ou définit l'alignement horizontal d'un contrôle GridView sur la page.

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

Valeur de propriété

HorizontalAlign

Une des valeurs de l'objet HorizontalAlign. La valeur par défaut est HorizontalAlign.NotSet.

Exemples

L’exemple suivant montre comment utiliser la HorizontalAlign propriété pour aligner un GridView contrôle sur le côté droit d’une page.


<%@ Page language="C#" %>

<!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 runat="server">
    <title>GridView HorizontalAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView HorizontalAlign Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        horizontalalign="Right"
        runat="server">
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView HorizontalAlign Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView HorizontalAlign Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        horizontalalign="Right"
        runat="server">
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

Remarques

Utilisez la HorizontalAlign propriété pour spécifier l’alignement horizontal d’un GridView contrôle dans la page. Le tableau suivant répertorie les différents styles d’alignement horizontal.

Valeur d’alignement Description
HorizontalAlign.NotSet L’alignement horizontal du GridView contrôle n’a pas été défini.
HorizontalAlign.Left Le GridView contrôle est aligné à gauche sur la page.
HorizontalAlign.Center Le GridView contrôle est centré sur la page.
HorizontalAlign.Right Le GridView contrôle est aligné à droite sur la page.
HorizontalAlign.Justify Le GridView contrôle est aligné à la fois avec les marges gauche et droite de la page.

S’applique à

Voir aussi