GridView.CellSpacing Właściwość

Definicja

Pobiera lub ustawia ilość miejsca między komórkami.

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

Wartość właściwości

Int32

Ilość miejsca w pikselach między komórkami. Wartość domyślna to 0.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą CellSpacing właściwości deklaratywnie ustawić ilość miejsca między komórkami kontrolki GridView .


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

Uwagi

Użyj właściwości , CellSpacing aby kontrolować odstępy między sąsiednimi komórkami w kontrolce GridView . To odstępy są stosowane zarówno w pionie, jak i w poziomie. Odstępy między komórkami są jednolite dla całej kontrolki. Nie można określić odstępów między poszczególnymi komórkami lub wierszami.

Uwaga

Jeśli ustawisz tę właściwość na wartość większą niż 0, a następnie ustawisz GridLines właściwość na wartość, która wyświetla obramowania komórek, zostanie wyświetlona luka między obramowaniami sąsiednich komórek. W takiej sytuacji CellSpacing właściwość kontroluje rozmiar luki.

Dotyczy

Zobacz też