Calendar.CellPadding Proprietà

Definizione

Ottiene o imposta la quantità di spazio tra il contenuto e il bordo di una cella.

public:
 property int CellPadding { int get(); void set(int value); };
[System.ComponentModel.Bindable(true)]
public int CellPadding { get; set; }
public int CellPadding { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.CellPadding : int with get, set
member this.CellPadding : int with get, set
Public Property CellPadding As Integer

Valore della proprietà

Distanza, espressa in pixel, tra il contenuto e il bordo di una cella. Il valore predefinito è 2.

Attributi

Eccezioni

La spaziatura interna della cella è minore di -1.

Esempio

Nell'esempio di codice seguente viene illustrato come usare la CellPadding proprietà per riempire ogni cella con 5 pixel.

<%@ 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"
           CellPadding="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"
           CellPadding="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>

Commenti

Utilizzare questa proprietà per controllare la spaziatura tra il contenuto di una cella e il bordo della cella. La quantità di spaziatura interna specificata viene aggiunta a tutti e quattro i lati di una cella. Non è possibile specificare dimensioni singole delle celle.

Nota

L'impostazione di questa proprietà su -1 indica che questa proprietà non è impostata nella tabella sottoposta a rendering.

Si applica a

Vedi anche