GridView.CellSpacing GridView.CellSpacing GridView.CellSpacing GridView.CellSpacing Property

Definición

Obtiene o establece la cantidad de espacio entre las celdas.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

Valor de propiedad

Cantidad de espacio, en píxeles, comprendido entre las celdas.The amount of space, in pixels, between cells. El valor predeterminado es 0.The default value is 0.

Ejemplos

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

Comentarios

Utilice la CellSpacing propiedad para controlar el espaciado entre las celdas GridView adyacentes del control.Use the CellSpacing property to control the spacing between adjacent cells in the GridView control. Este espaciado se aplica tanto vertical como horizontalmente.This spacing is applied both vertically and horizontally. El espaciado de celda es uniforme para todo el control.The cell spacing is uniform for the entire control. No se puede especificar el espaciado de celdas individual entre filas o columnas.Individual cell spacing between rows or columns cannot be specified.

Nota

Si establece esta propiedad en un valor mayor que 0 y, a continuación, GridLines establece la propiedad en un valor que muestra los bordes de la celda, se muestra un espacio entre los bordes de las celdas adyacentes.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. En esta situación, la CellSpacing propiedad controla el tamaño de la brecha.In this situation, the CellSpacing property controls the size of the gap.

Se aplica a

Consulte también: