GridView.CellSpacing Propiedad

Definición

Obtiene o establece la cantidad de espacio entre las celdas.

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

Valor de propiedad

Int32

Cantidad de espacio, en píxeles, comprendido entre las celdas. El valor predeterminado es 0.

Ejemplos

En el ejemplo siguiente se muestra cómo usar la CellSpacing propiedad para establecer mediante declaración la cantidad de espacio entre las celdas de un 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>

Comentarios

Utilice la CellSpacing propiedad para controlar el espaciado entre celdas adyacentes del GridView control . Este espaciado se aplica tanto vertical como horizontalmente. El espaciado de celdas es uniforme para todo el control. No se puede especificar el espaciado de celdas individuales entre filas o columnas.

Nota

Si establece esta propiedad en un valor mayor que 0 y, a continuación, establece la GridLines propiedad en un valor que muestra los bordes de la celda, se muestra un intervalo entre los bordes de las celdas adyacentes. En esta situación, la CellSpacing propiedad controla el tamaño de la brecha.

Se aplica a

Consulte también