DetailsView.CellSpacing DetailsView.CellSpacing DetailsView.CellSpacing DetailsView.CellSpacing Property

Definizione

Ottiene o imposta la distanza tra le celle.Gets or sets the amount of space between cells.

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

Valore della proprietà

Consente di specificare la quantità di spazio tra le celle, espressa in pixel.The amount of space, in pixels, between cells. Il valore predefinito è 0.The default value is 0.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato CellSpacing come utilizzare la proprietà per specificare la quantità di spaziatura tra celle adiacenti.The following code example demonstrates how to use the CellSpacing property to specify the amount of spacing between adjacent cells.


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

Commenti

Utilizzare la CellSpacing proprietà per controllare la spaziatura tra celle adiacenti DetailsView nel controllo.Use the CellSpacing property to control the spacing between adjacent cells in the DetailsView control. Questa spaziatura viene applicata sia verticalmente che orizzontalmente.This spacing is applied both vertically and horizontally. La spaziatura delle celle è uniforme per l'intero controllo.The cell spacing is uniform for the entire control. Non è possibile specificare la spaziatura delle singole celle tra le righe o le colonne.Individual cell spacing between rows or columns cannot be specified.

Nota

Se si imposta questa proprietà su un valore maggiore di 0 e quindi si imposta la GridLines proprietà su un valore che Visualizza i bordi delle celle, viene visualizzato un gap tra i bordi delle celle adiacenti.If you set this property to a value greater than 0, and then set the GridLines property to a value that displays the cell borders, a gap is displayed between the borders of adjacent cells. In questa situazione, la CellSpacing proprietà controlla le dimensioni del gap.In this situation, the CellSpacing property controls the size of the gap.

Per regolare la spaziatura tra il contenuto di una cella e il bordo della cella, utilizzare CellPadding la proprietà.To adjust the spacing between the contents of a cell and the cell's border, use the CellPadding property.

Si applica a

Vedi anche