Calendar.OtherMonthDayStyle プロパティ
アセンブリ: System.Web (system.web.dll 内)
構文
Calendar コントロールの日付のうち、表示された月にない日付のスタイル プロパティを格納している TableItemStyle。既定値は空の TableItemStyle です。
このプロパティを使用して、Calendar コントロールの日付のうち表示された月にない日付のスタイル プロパティを指定します。OtherMonthDayStyle プロパティが設定されていない場合は、DayStyle プロパティで指定したスタイルが使用されます。
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>
<%@ 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>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Calendar.OtherMonthDayStyle プロパティのページへのリンク