GridView.HorizontalAlign プロパティ

定義

ページ上の GridView コントロールの水平方向の配置を取得または設定します。

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

プロパティ値

HorizontalAlign

HorizontalAlign 値のいずれか 1 つ。 既定値は、HorizontalAlign.NotSet です。

次の例では、プロパティを HorizontalAlign 使用してページの右側にコントロールを配置 GridView する方法を示します。


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

注釈

プロパティを HorizontalAlign 使用して、ページ内のコントロールの水平方向の GridView 配置を指定します。 次の表に、さまざまな水平方向の配置スタイルを示します。

配置値 [説明]
HorizontalAlign.NotSet コントロールの水平方向の GridView 配置が設定されていません。
HorizontalAlign.Left コントロールは GridView ページ上で左揃えになっています。
HorizontalAlign.Center コントロールは GridView ページの中央に配置されます。
HorizontalAlign.Right GridViewコントロールはページ上で右揃えになっています。
HorizontalAlign.Justify コントロールは GridView 、ページの左余白と右余白の両方に揃えられます。

適用対象

こちらもご覧ください