次の方法で共有


Calendar コンストラクタ

Calendar クラスの新しいインスタンスを初期化します。

Public Sub New()
[C#]
public Calendar();
[C++]
public: Calendar();
[JScript]
public function Calendar();

解説

このコンストラクタを使用して、 Calendar クラスの新しいインスタンスを作成し、初期化します。

使用例

[Visual Basic, C#, JScript] Calendar クラスの新しいインスタンスを作成および初期化する方法を次の例に示します。

 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">
        Sub Page_Load(sender As Object, e As EventArgs)
            ' Create new Calendar control.
            Dim calendar1 as Calendar = New Calendar

            ' Set Calendar properties.
            calendar1.OtherMonthDayStyle.ForeColor=System.Drawing.Color.LightGray
            calendar1.TitleStyle.BackColor=System.Drawing.Color.Blue
            calendar1.TitleStyle.ForeColor=System.Drawing.Color.White
            calendar1.DayStyle.BackColor=System.Drawing.Color.Gray
            calendar1.SelectionMode=CalendarSelectionMode.DayWeekMonth
            calendar1.ShowNextPrevMonth=true

            ' Add Calendar control to Controls collection.
            Form1.Controls.Add(calendar1)
        End Sub 'Page_Load 
   </script>

</head>
<body>

   <form id="Form1" runat="server">

      <h3>Calendar Example</h3>
            
   </form>
        

</body>
</html>
   

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      void Page_Load(Object sender, EventArgs e)
      {
         // Create new Calendar control.
         Calendar calendar1 = new Calendar();

         // Set Calendar properties.
         calendar1.OtherMonthDayStyle.ForeColor=System.Drawing.Color.LightGray;
         calendar1.TitleStyle.BackColor=System.Drawing.Color.Blue;
         calendar1.TitleStyle.ForeColor=System.Drawing.Color.White;
         calendar1.DayStyle.BackColor=System.Drawing.Color.Gray;
         calendar1.SelectionMode=CalendarSelectionMode.DayWeekMonth;
         calendar1.ShowNextPrevMonth=true;

         // Add Calendar control to Controls collection.
         Form1.Controls.Add(calendar1);
      }

   </script>

</head>
<body>

   <form id="Form1" runat="server">

      <h3>Calendar Example</h3>
            
   </form>
        

</body>
</html>
   

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      function Page_Load(sender : Object, e : EventArgs)
      {
         // Create new Calendar control.
         var calendar1 : Calendar = new Calendar();

         // Set Calendar properties.
         calendar1.OtherMonthDayStyle.ForeColor=System.Drawing.Color.LightGray;
         calendar1.TitleStyle.BackColor=System.Drawing.Color.Blue;
         calendar1.TitleStyle.ForeColor=System.Drawing.Color.White;
         calendar1.DayStyle.BackColor=System.Drawing.Color.Gray;
         calendar1.SelectionMode=CalendarSelectionMode.DayWeekMonth;
         calendar1.ShowNextPrevMonth=true;

         // Add Calendar control to Controls collection.
         Form1.Controls.Add(calendar1);
      }

   </script>

</head>
<body>

   <form id="Form1" runat="server">

      <h3>Calendar Example</h3>
            
   </form>
        

</body>
</html>
   

[C++] C++ のサンプルはありません。Visual Basic、C#、および JScript のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

Calendar クラス | Calendar メンバ | System.Web.UI.WebControls 名前空間