Calendar.SelectionMode プロパティ

定義

ユーザーが 1 つの日付、1 つの週、または 1 つの月のいずれかを選択できるかを指定する Calendar コントロールの日付選択モードを取得または設定します。

public:
 property System::Web::UI::WebControls::CalendarSelectionMode SelectionMode { System::Web::UI::WebControls::CalendarSelectionMode get(); void set(System::Web::UI::WebControls::CalendarSelectionMode value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.WebControls.CalendarSelectionMode SelectionMode { get; set; }
public System.Web.UI.WebControls.CalendarSelectionMode SelectionMode { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.SelectionMode : System.Web.UI.WebControls.CalendarSelectionMode with get, set
member this.SelectionMode : System.Web.UI.WebControls.CalendarSelectionMode with get, set
Public Property SelectionMode As CalendarSelectionMode

プロパティ値

CalendarSelectionMode 値のいずれか 1 つ。 既定値は Day です。

属性

例外

指定された選択モードが CalendarSelectionMode 値ではありません。

次のコード例では、 プロパティを SelectionMode 使用して、1 日、1 週間、または月全体で日付を選択できるようにする方法を示します。

<%@ 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"
           SelectionMode="DayWeekMonth"/>
            
   </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"
           SelectionMode="DayWeekMonth"/>
            
   </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 day selection mode.
         Calendar1.SelectionMode = 
            (CalendarSelectionMode)ModeList.SelectedIndex;

      }
  
   </script>
  
<head runat="server">
    <title> Calendar SelectionMode Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> Calendar SelectionMode Example </h3>

      Choose the date selection mode.

      <br /><br /> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
           runat="server"/>

      <br /><br />

      <table cellpadding="5">

         <tr>

            <td>

               Mode:

            </td>

         </tr>

         <tr>

            <td>

               <asp:DropDownList id="ModeList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem> None </asp:ListItem>
                  <asp:ListItem Selected="True"> Day </asp:ListItem>
                  <asp:ListItem> DayWeek </asp:ListItem>
                  <asp:ListItem> DayWeekMonth </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 day selection mode.
         Calendar1.SelectionMode = _
            CType(ModeList.SelectedIndex, CalendarSelectionMode)

      End Sub
  
   </script>
  
<head runat="server">
    <title> Calendar SelectionMode Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> Calendar SelectionMode Example </h3>

      Choose the date selection mode.

      <br /><br /> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
           runat="server"/>

      <br /><br />

      <table cellpadding="5">

         <tr>

            <td>

               Mode:

            </td>

         </tr>

         <tr>

            <td>

               <asp:DropDownList id="ModeList"
                    AutoPostBack="True"
                    OnSelectedIndexChanged="Selection_Change"
                    runat="server">

                  <asp:ListItem> None </asp:ListItem>
                  <asp:ListItem Selected="True"> Day </asp:ListItem>
                  <asp:ListItem> DayWeek </asp:ListItem>
                  <asp:ListItem> DayWeekMonth </asp:ListItem>

               </asp:DropDownList>

            </td>

         </tr>
  
      </table>
  
   </form>

</body>
</html>

注釈

コントロールの SelectionMode 日付選択モードを指定するには、 プロパティを Calendar 使用します。 このプロパティは、列挙値の 1 つで設定されます CalendarSelectionMode 。 ユーザーが 1 日、1 週間、または 1 か月全体を選択できるか、日付選択機能を完全に無効にするかを指定できます。

このプロパティを または CalendarSelectionMode.DayWeekMonthCalendarSelectionMode.DayWeek設定すると、週と月の選択コントロールを含む追加のセレクター列がコントロールの最初の列にCalendar表示されます。 プロパティを SelectorStyle 使用して、この列の外観をカスタマイズします。

日付の選択を無効にするには、このプロパティを に設定します CalendarSelectionMode.None

適用対象

こちらもご覧ください