GridView.CellSpacing Proprietà

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 seguente viene illustrato come utilizzare la CellSpacing proprietà per impostare in modo dichiarativo la quantità di spazio tra le GridView celle di un controllo.The following example demonstrates how to use the CellSpacing property to declaratively set the amount of space between the cells of a GridView control.


<%@ 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 CellPadding and CellSpacing Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView CellPadding and CellSpacing Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        cellpadding="10"
        cellspacing="5"
        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="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </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 CellPadding and CellSpacing Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView CellPadding and CellSpacing Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        cellpadding="10"
        cellspacing="5"
        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="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

Commenti

Utilizzare la CellSpacing proprietà per controllare la spaziatura tra celle adiacenti GridView nel controllo.Use the CellSpacing property to control the spacing between adjacent cells in the GridView 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 GridLines la 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.

Si applica a

Vedi anche