DetailsView.CellPadding プロパティ

定義

セルの内容とセルの境界線との間隔を取得または設定します。

public:
 virtual property int CellPadding { int get(); void set(int value); };
public virtual int CellPadding { get; set; }
member this.CellPadding : int with get, set
Public Overridable Property CellPadding As Integer

プロパティ値

セルの内容とセルの境界線の間の間隔 (ピクセル単位)。 既定値は -1 です。このプロパティが設定されていないことを示します。

次のコード例では、 プロパティを CellPadding 使用して、セルの内容とセルの罫線の間隔を指定する方法を示します。


<%@ 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 CellPadding and CellSpacing Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView CellPadding and CellSpacing Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          cellpadding="10"
          cellspacing="5" 
          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 CellPadding and CellSpacing Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView CellPadding and CellSpacing Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          cellpadding="10"
          cellspacing="5" 
          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>

注釈

プロパティを CellPadding 使用して、セルの内容とセルの境界線の間隔を制御します。 指定された埋め込み量は、セルの 4 つの辺すべてに追加されます。

コントロールの同じ列内のすべてのセルの DetailsView 幅は同じです。 埋め込み量が最も広いセルに適用され、列内の他のすべてのセルがそのセル幅に合わせて調整されます。 同様に、同じ行のすべてのセルの高さは同じです。 埋め込み量は行の最も高いセルに適用され、行内の他のすべてのセルはそのセルの高さに合わせて調整されます。 個々のセル サイズを指定することはできません。

セル間の間隔を調整するには、 プロパティを CellSpacing 使用します。

適用対象

こちらもご覧ください