DetailsView.CellSpacing Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define a quantidade de espaço entre as células.
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 Propriedade
A quantidade de espaço, em píxeis, entre células. O valor padrão é 0.
Exemplos
O exemplo de código seguinte demonstra como usar a CellSpacing propriedade para especificar a quantidade de espaçamento entre células adjacentes.
<%@ 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>
Observações
Use a CellSpacing propriedade para controlar o espaçamento entre as células adjacentes no DetailsView controlo. Este espaçamento é aplicado tanto vertical como horizontalmente. O espaçamento das células é uniforme para todo o controlo. O espaçamento individual entre as linhas ou colunas não pode ser especificado.
Note
Se definir esta propriedade para um valor superior a 0, e depois definir a GridLines propriedade para um valor que mostre as bordas das células, é exibido um espaço entre as bordas das células adjacentes. Nesta situação, a CellSpacing propriedade controla o tamanho da lacuna.
Para ajustar o espaçamento entre o conteúdo de uma célula e a borda da célula, use a CellPadding propriedade.