DetailsView.CaptionAlign プロパティ

定義

DetailsView コントロールの HTML キャプション要素の水平位置または垂直位置を取得または設定します。 このプロパティは、補助技術デバイスのユーザーにとって、より使いやすいコントロールを実現するための手段として用意されています。

public:
 virtual property System::Web::UI::WebControls::TableCaptionAlign CaptionAlign { System::Web::UI::WebControls::TableCaptionAlign get(); void set(System::Web::UI::WebControls::TableCaptionAlign value); };
public virtual System.Web.UI.WebControls.TableCaptionAlign CaptionAlign { get; set; }
member this.CaptionAlign : System.Web.UI.WebControls.TableCaptionAlign with get, set
Public Overridable Property CaptionAlign As TableCaptionAlign

プロパティ値

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

例外

指定した値が TableCaptionAlign 列挙値ではありません。

次のコード例では、 プロパティを CaptionAlign 使用して、コントロールの HTML caption 要素を DetailsView コントロールの左側にレンダリングする必要があることを指定する方法を示します。


<%@ 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>DetailsView Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView Caption and CaptionAlign Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          caption="Customer Details"
          captionalign="Left"  
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID], 
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] 
            From [Customers]">
        </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>DetailsView Caption and CaptionAlign Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView Caption and CaptionAlign Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          caption="Customer Details"
          captionalign="Left"  
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID], 
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] 
            From [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

注釈

コントロール内の CaptionAlign HTML キャプション要素の水平方向または垂直方向の位置を指定するには、 プロパティを DetailsView 使用します。 このプロパティは、補助技術デバイスのユーザーにとって、より使いやすいコントロールを実現するための手段として用意されています。

このプロパティは、列挙値のいずれかを使用して設定されます TableCaptionAlign 。 次の表に、使用可能な値を示します。

説明
TableCaptionAlign.Bottom キャプション要素は、テーブルの下部に揃えて配置されます。
TableCaptionAlign.Left キャプション要素は、テーブルの左側に揃えて配置されます。
TableCaptionAlign.NotSet caption 要素の配置が設定されていません。
TableCaptionAlign.Right キャプション要素は、テーブルの右側に揃えて配置されます。
TableCaptionAlign.Top キャプション要素は、テーブルの上部に揃えて配置されます。

コントロールに対する追加の DetailsView アクセシビリティ サポートは、 Caption プロパティによって提供されます。 プロパティを Caption 使用して、コントロール内の HTML キャプション要素にレンダリングするテキストを DetailsView 指定します。

CaptionAlign 値はビューステートに格納されます。

適用対象

こちらもご覧ください