GridView.CellPadding Propriedade

Definição

Obtém ou define a quantidade de espaço entre o conteúdo e a borda de uma célula.Gets or sets the amount of space between the contents of a cell and the cell's border.

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

Valor da propriedade

Int32

A quantidade de espaço, em pixels, entre o conteúdo e a borda de uma célula.The amount of space, in pixels, between the contents of a cell and the cell's border. O valor padrão é -1, que indica que essa propriedade não está definida.The default value is -1, which indicates that this property is not set.

Exemplos

O exemplo a seguir demonstra como usar a CellPadding propriedade para definir declarativamente a quantidade de espaço entre o conteúdo de uma célula e a borda da célula.The following example demonstrates how to use the CellPadding property to declaratively set the amount of space between the contents of a cell and the cell's border.


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

Comentários

Use a CellPadding propriedade para controlar o espaçamento entre o conteúdo de uma célula e a borda da célula.Use the CellPadding property to control the spacing between the contents of a cell and the cell's border. A quantidade de preenchimento especificada é adicionada a todos os quatro lados da célula.The padding amount specified is added to all four sides of the cell.

Todas as células na mesma coluna de um GridView controle têm a mesma largura.All cells in the same column of a GridView control have the same width. O valor de preenchimento é aplicado à célula mais larga e todas as outras células na coluna têm essa largura de célula.The padding amount is applied to the widest cell and all other cells in the column have this cell width. Da mesma forma, todas as células na mesma linha têm a mesma altura.Similarly, all cells in the same row have the same height. O valor de preenchimento é aplicado à célula mais alta na linha e todas as outras células na linha têm essa altura de célula.The padding amount is applied to the tallest cell in the row and all other cells in the row have this cell height. Não é possível especificar tamanhos de células individuais.Individual cell sizes cannot be specified.

Aplica-se a

Confira também