Calendar.CellSpacing 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定儲存格之間的間距。
public:
property int CellSpacing { int get(); void set(int value); };
[System.ComponentModel.Bindable(true)]
public int CellSpacing { get; set; }
public int CellSpacing { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.CellSpacing : int with get, set
member this.CellSpacing : int with get, set
Public Property CellSpacing As Integer
屬性值
儲存格之間的間距數 (以像素為單位)。 預設值是 0
。
- 屬性
例外狀況
指定的儲存格間距小於 -1。
範例
下列程式碼範例示範如何使用 CellSpacing 屬性將儲存格間距 5 圖元。
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>
<title>Calendar Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Calendar Example</h3>
<asp:Calendar id="calendar1" runat="server"
CellSpacing="5"
ShowGridLines="true"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>
<title>Calendar Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Calendar Example</h3>
<asp:Calendar id="calendar1" runat="server"
CellSpacing="5"
ShowGridLines="true"/>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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" >
<script runat="server" >
void Selection_Change(Object sender, EventArgs e)
{
// Set the cell padding and cell spacing for the Calendar control
// based on the values selected from the DropDownList control.
Calendar1.CellPadding = CellPaddingList.SelectedIndex;
Calendar1.CellSpacing = CellSpacingList.SelectedIndex;
}
</script>
<head runat="server">
<title> Calendar CellPadding and CellSpacing Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar CellPadding and CellSpacing Example </h3>
Select the cell padding and cell spacing values.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
Cell padding:
</td>
<td>
Cell spacing:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="CellPaddingList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> 0 </asp:ListItem>
<asp:ListItem> 1 </asp:ListItem>
<asp:ListItem Selected="True"> 2 </asp:ListItem>
<asp:ListItem> 3 </asp:ListItem>
<asp:ListItem> 4 </asp:ListItem>
<asp:ListItem> 5 </asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList id="CellSpacingList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem Selected="True"> 0 </asp:ListItem>
<asp:ListItem> 1 </asp:ListItem>
<asp:ListItem> 2 </asp:ListItem>
<asp:ListItem> 3 </asp:ListItem>
<asp:ListItem> 4 </asp:ListItem>
<asp:ListItem> 5 </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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" >
<script runat="server" >
Sub Selection_Change(sender As Object, e As EventArgs)
' Set the cell padding and cell spacing for the Calendar control
' based on the values selected from the DropDownList control.
Calendar1.CellPadding = CellPaddingList.SelectedIndex
Calendar1.CellSpacing = CellSpacingList.SelectedIndex
End Sub
</script>
<head runat="server">
<title> Calendar CellPadding and CellSpacing Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar CellPadding and CellSpacing Example </h3>
Select the cell padding and cell spacing values.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
Cell padding:
</td>
<td>
Cell spacing:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="CellPaddingList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> 0 </asp:ListItem>
<asp:ListItem> 1 </asp:ListItem>
<asp:ListItem Selected="True"> 2 </asp:ListItem>
<asp:ListItem> 3 </asp:ListItem>
<asp:ListItem> 4 </asp:ListItem>
<asp:ListItem> 5 </asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList id="CellSpacingList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem Selected="True"> 0 </asp:ListItem>
<asp:ListItem> 1 </asp:ListItem>
<asp:ListItem> 2 </asp:ListItem>
<asp:ListItem> 3 </asp:ListItem>
<asp:ListItem> 4 </asp:ListItem>
<asp:ListItem> 5 </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
備註
使用這個屬性來控制行事曆中個別儲存格之間的間距。 此間距會垂直和水準套用。
注意
將這個屬性設定為 -1
,表示這個屬性未在轉譯的資料表中設定。