Calendar.OtherMonthDayStyle プロパティ

Calendar コントロールの日付のうち、表示された月にない日付のスタイル プロパティを取得します。

Public ReadOnly Property OtherMonthDayStyle As TableItemStyle
[C#]
public TableItemStyle OtherMonthDayStyle {get;}
[C++]
public: __property TableItemStyle* get_OtherMonthDayStyle();
[JScript]
public function get OtherMonthDayStyle() : TableItemStyle;

プロパティ値

Calendar コントロールの日付のうち、表示された月にない日付のスタイル プロパティを格納している TableItemStyle 。既定値は空の TableItemStyle オブジェクトです。

解説

このプロパティを使用して、 Calendar コントロールの日付のうち表示された月にない日付のスタイル プロパティを指定します。 OtherMonthDayStyle プロパティが設定されていない場合は、 DayStyle プロパティで指定したスタイルが使用されます。

制御できるさまざまなスタイル プロパティの詳細については、 TableItemStyle のトピックを参照してください。

使用例

[Visual Basic, C#] OtherMonthDayStyle プロパティを使用して、 Calendar コントロールの日のうち現在表示されている月にない日を明るい灰色の前景色で表示するように指定する方法を次の例に示します。

 
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Drawing" %>

<html>
<head>

   <script runat="server">

      Sub Index_Changed(sender As Object, e As EventArgs)

         ' Set the foreground color of days not in the current
         ' month to the color selected from the DropDownList control.
         Calendar1.OtherMonthDayStyle.ForeColor = _
            Color.FromName(ColorList.SelectedItem.Value)

      End Sub

   </script>

</head>
<body>

   <form runat="server">

      <h3>Calendar OtherMonthDayStyle Example</h3>

      <asp:Calendar id="Calendar1" runat="server">

         <OtherMonthDayStyle ForeColor="LightGray">
         </OtherMonthDayStyle>

      </asp:Calendar>

      <br><br>

      Select a color for the days not in the current month:

      <br>     
 
      <asp:DropDownList id="ColorList"
           AutoPostBack="True"
           OnSelectedIndexChanged="Index_Changed"
           runat="server">

         <asp:ListItem Value="DarkGray">Dark Gray</asp:ListItem>
         <asp:ListItem Value="LightGray" Selected="True">Light Gray</asp:ListItem>
         <asp:ListItem Value="DarkKhaki">Dark Khaki</asp:ListItem>
         <asp:ListItem Value="Khaki">Khaki</asp:ListItem>
         <asp:ListItem Value="White">White</asp:ListItem>

      </asp:DropDownList>      
            
   </form>
        
</body>
</html>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Drawing" %>

<html>
<head>

   <script runat="server">

      void Index_Changed(Object sender, EventArgs e)
      {

         // Set the foreground color of days not in the current
         // month to the color selected from the DropDownList control.
         Calendar1.OtherMonthDayStyle.ForeColor = 
            Color.FromName(ColorList.SelectedItem.Value);

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>Calendar OtherMonthDayStyle Example</h3>

      <asp:Calendar id="Calendar1" runat="server">

         <OtherMonthDayStyle ForeColor="LightGray">
         </OtherMonthDayStyle>

      </asp:Calendar>

      <br><br>

      Select a color for the days not in the current month:

      <br>     
 
      <asp:DropDownList id="ColorList"
           AutoPostBack="True"
           OnSelectedIndexChanged="Index_Changed"
           runat="server">

         <asp:ListItem Value="DarkGray">Dark Gray</asp:ListItem>
         <asp:ListItem Value="LightGray" Selected="True">Light Gray</asp:ListItem>
         <asp:ListItem Value="DarkKhaki">Dark Khaki</asp:ListItem>
         <asp:ListItem Value="Khaki">Khaki</asp:ListItem>
         <asp:ListItem Value="White">White</asp:ListItem>

      </asp:DropDownList>      
            
   </form>
        
</body>
</html>

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

必要条件

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

参照

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