GridView.CellSpacing Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur jumlah ruang antar sel.
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
Nilai Properti
Jumlah ruang, dalam piksel, di antara sel. Nilai defaultnya adalah 0.
Contoh
Contoh berikut menunjukkan cara menggunakan CellSpacing properti untuk secara deklaratif mengatur jumlah ruang antara sel GridView kontrol.
<%@ 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>
Keterangan
CellSpacing Gunakan properti untuk mengontrol penspasian antara sel yang berdekatan GridView dalam kontrol. Penspasian ini diterapkan baik secara vertikal maupun horizontal. Penspasian sel seragam untuk seluruh kontrol. Penspasian sel individual antara baris atau kolom tidak dapat ditentukan.
Nota
Jika Anda mengatur properti ini ke nilai yang lebih besar dari 0 lalu mengatur GridLines properti ke nilai yang menampilkan batas sel, celah ditampilkan di antara batas sel yang berdekatan. Dalam situasi ini, CellSpacing properti mengontrol ukuran kesenjangan.