GridView.HorizontalAlign Propriedade

Definição

Obtém ou define o alinhamento horizontal de um controle GridView na página.

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

Valor da propriedade

HorizontalAlign

Um dos valores de HorizontalAlign. O padrão é HorizontalAlign.NotSet.

Exemplos

O exemplo a seguir demonstra como usar a HorizontalAlign propriedade para alinhar um GridView controle no lado direito de uma página.


<%@ 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>

Comentários

Use a HorizontalAlign propriedade para especificar o alinhamento horizontal de um GridView controle dentro da página. A tabela a seguir lista os diferentes estilos de alinhamento horizontal.

Valor de alinhamento Descrição
HorizontalAlign.NotSet O alinhamento horizontal do GridView controle não foi definido.
HorizontalAlign.Left O GridView controle é alinhado à esquerda na página.
HorizontalAlign.Center O GridView controle é centralizado na página.
HorizontalAlign.Right O GridView controle está alinhado à direita na página.
HorizontalAlign.Justify O GridView controle está alinhado com as margens esquerda e direita da página.

Aplica-se a

Confira também