HtmlTable.CellSpacing-Eigenschaft
Ruft den Abstand zwischen angrenzenden Zellen im HtmlTable-Steuerelement in Pixel ab oder legt diesen fest.
Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public Property CellSpacing As Integer
'Usage
Dim instance As HtmlTable
Dim value As Integer
value = instance.CellSpacing
instance.CellSpacing = value
public int CellSpacing { get; set; }
public:
property int CellSpacing {
int get ();
void set (int value);
}
/** @property */
public int get_CellSpacing ()
/** @property */
public void set_CellSpacing (int value)
public function get CellSpacing () : int
public function set CellSpacing (value : int)
Eigenschaftenwert
Der Abstand zwischen angrenzenden Zellen im HtmlTable-Steuerelement in Pixel. Der Standardwert ist -1 und gibt an, dass diese Eigenschaft nicht festgelegt ist.
Hinweise
Mit der CellSpacing-Eigenschaft können Sie den Abstand zwischen einzelnen Zellen im HtmlTable-Steuerelement steuern. Dieser Abstand wird sowohl vertikal als auch horizontal angewendet.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie mit der CellSpacing-Eigenschaft der Abstand der Zellen im HtmlTable-Steuerelement programmgesteuert festgelegt wird.
<%@ Page Language="VB" AutoEventWireup="True" %>
<script runat="server">
Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
' Set the HtmlTable properties according to the
' user selections.
Table1.CellSpacing = CInt(SpacingSelect.Value)
Table1.CellPadding = CInt(PaddingSelect.Value)
Table1.Align = AlignSelect.Value
End Sub
</script>
<html>
<head>
<title>HtmlTable Example</title>
</head>
<body>
<form runat="server">
<h3>HtmlTable Example</h3>
<table id="Table1"
Border="1"
BorderColor="black"
runat="server">
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
<th>
Column 3
</th>
</tr>
<tr>
<td>
Cell 1
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
</tr>
<tr>
<td>
Cell 4
</td>
<td>
Cell 5
</td>
<td>
Cell 6
</td>
</tr>
</table>
<br><br><br><br><br><br><br><br>
<hr>
Select the display settings: <br><br>
Align:
<select id="AlignSelect"
runat="server">
<option Value="Left">Left</option>
<option Value="Center">Center</option>
<option Value="Right">Right</option>
</select>
CellPadding:
<select id="PaddingSelect"
runat="server">
<option Value="0">0</option>
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
CellSpacing:
<select id="SpacingSelect"
runat="server">
<option Value="0">0</option>
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
<br><br>
<input type="button"
value="Generate Table"
OnServerClick ="Button_Click"
runat="server"/>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<script runat="server">
void Button_Click(Object sender, EventArgs e)
{
// Set the HtmlTable properties according to the
// user selections.
Table1.CellSpacing = Convert.ToInt32(SpacingSelect.Value);
Table1.CellPadding = Convert.ToInt32(PaddingSelect.Value);
Table1.Align = AlignSelect.Value;
}
</script>
<html>
<head>
<title>HtmlTable Example</title>
</head>
<body>
<form runat="server">
<h3>HtmlTable Example</h3>
<table id="Table1"
Border="1"
BorderColor="black"
runat="server">
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
<th>
Column 3
</th>
</tr>
<tr>
<td>
Cell 1
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
</tr>
<tr>
<td>
Cell 4
</td>
<td>
Cell 5
</td>
<td>
Cell 6
</td>
</tr>
</table>
<br><br><br><br><br><br><br><br>
<hr>
Select the display settings: <br><br>
Align:
<select id="AlignSelect"
runat="server">
<option Value="Left">Left</option>
<option Value="Center">Center</option>
<option Value="Right">Right</option>
</select>
CellPadding:
<select id="PaddingSelect"
runat="server">
<option Value="0">0</option>
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
CellSpacing:
<select id="SpacingSelect"
runat="server">
<option Value="0">0</option>
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
<br><br>
<input type="button"
value="Generate Table"
OnServerClick ="Button_Click"
runat="server"/>
</form>
</body>
</html>
<%@ Page Language="JScript" AutoEventWireup="True" %>
<script runat="server">
function Button_Click(sender : Object, e : EventArgs)
{
// Set the HtmlTable properties according to the
// user selections.
Table1.CellSpacing = Convert.ToInt32(SpacingSelect.Value);
Table1.CellPadding = Convert.ToInt32(PaddingSelect.Value);
Table1.Align = AlignSelect.Value;
}
</script>
<html>
<head>
<title>HtmlTable Example</title>
</head>
<body>
<form runat="server">
<h3>HtmlTable Example</h3>
<table id="Table1"
Border="1"
BorderColor="black"
runat="server">
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
<th>
Column 3
</th>
</tr>
<tr>
<td>
Cell 1
</td>
<td>
Cell 2
</td>
<td>
Cell 3
</td>
</tr>
<tr>
<td>
Cell 4
</td>
<td>
Cell 5
</td>
<td>
Cell 6
</td>
</tr>
</table>
<br><br><br><br><br><br><br><br>
<hr>
Select the display settings: <br><br>
Align:
<select id="AlignSelect"
runat="server">
<option Value="Left">Left</option>
<option Value="Center">Center</option>
<option Value="Right">Right</option>
</select>
CellPadding:
<select id="PaddingSelect"
runat="server">
<option Value="0">0</option>
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
CellSpacing:
<select id="SpacingSelect"
runat="server">
<option Value="0">0</option>
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
<br><br>
<input type="button"
value="Generate Table"
OnServerClick ="Button_Click"
runat="server"/>
</form>
</body>
</html>
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
HtmlTable-Klasse
HtmlTable-Member
System.Web.UI.HtmlControls-Namespace
HtmlTable.Align-Eigenschaft
HtmlTable.CellPadding-Eigenschaft