This documentation is archived and is not being maintained.
Calendar.CellSpacing Property
.NET Framework 1.1
Gets or sets the amount of space between cells.
[Visual Basic] Public Property CellSpacing As Integer [C#] public int CellSpacing {get; set;} [C++] public: __property int get_CellSpacing(); public: __property void set_CellSpacing(int); [JScript] public function get CellSpacing() : int; public function set CellSpacing(int);
Property Value
The amount of space (in pixels) between cells. The default value is 0.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentOutOfRangeException | The specified cell spacing is less than -1. |
Remarks
Use this property to control the spacing between individual cells in the calendar. This spacing is applied both vertically and horizontally.
Note Setting this property to -1 indicates that this property is not set in the rendered table.
Example
[Visual Basic, C#, JScript] The following sample demonstates how to use the CellSpacing property to space the cells apart by 5 pixels.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" CellSpacing="5" ShowGridLines="true"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" CellSpacing="5" ShowGridLines="true"/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>Calendar Example</h3> <asp:Calendar id="calendar1" runat="server" CellSpacing="5" ShowGridLines="true"/> </form> </body> </html> [Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <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> <body> <form 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> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <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> <body> <form 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> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
Calendar Class | Calendar Members | System.Web.UI.WebControls Namespace | CellPadding
Show: