MonthChangedEventHandler デリゲート
アセンブリ: System.Web (system.web.dll 内)

/** @delegate */ public delegate void MonthChangedEventHandler ( Object sender, MonthChangedEventArgs e )

VisibleMonthChanged イベントは、翌月または前月を表示するために Calendar コントロールのナビゲーション コントロールをクリックしたときに発生します。
MonthChangedEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「イベントとデリゲート」を参照してください。

Calendar コントロールが前月に移動したか翌月に移動したかを Label に表示するために、VisibleMonthChanged イベントのハンドラを指定およびコード化する方法を次の例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub MonthChange(sender As Object, e As MonthChangedEventArgs) If e.NewDate.Month > e.PreviousDate.Month Then Message.Text = "You moved forward one month." Else Message.Text = "You moved backwards one month." End If End Sub </script> </head> <body> <form runat="server"> <h3> Calendar VisibleMonthChanged Example </h3> Select a different month on the calendar. <br><br> <asp:Calendar id="Calendar1" runat="server" OnVisibleMonthChanged="MonthChange"> <WeekendDayStyle BackColor="gray"> </WeekendDayStyle> </asp:Calendar> <hr> <table border="1"> <tr bgcolor="Silver"> <th> Month navigation direction </th> </tr> <tr> <td> <asp:Label id="Message" Text="Starting Month." runat="server"/> </td> </tr> </table> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void MonthChange(Object sender, MonthChangedEventArgs e) { if (e.NewDate.Month > e.PreviousDate.Month) { Message.Text = "You moved forward one month."; } else { Message.Text = "You moved backwards one month."; } } </script> </head> <body> <form runat="server"> <h3> Calendar VisibleMonthChanged Example </h3> Select a different month on the calendar. <br><br> <asp:Calendar id="Calendar1" runat="server" OnVisibleMonthChanged="MonthChange"> <WeekendDayStyle BackColor="gray"> </WeekendDayStyle> </asp:Calendar> <hr> <table border="1"> <tr bgcolor="Silver"> <th> Month navigation direction </th> </tr> <tr> <td> <asp:Label id="Message" Text="Starting month." runat="server"/> </td> </tr> </table> </form> </body> </html>
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub MonthChange(sender As Object, e As MonthChangedEventArgs) If e.NewDate.Month > e.PreviousDate.Month Then Message.Text = "You moved forward one month." Else Message.Text = "You moved backwards one month." End If End Sub Sub Page_Load(sender As Object, e As EventArgs) ' Manually register the event-handling method for the ' VisibleMonthChanged event of the Calendar control. AddHandler Calendar1.VisibleMonthChanged, AddressOf MonthChange End Sub </script> </head> <body> <form runat="server"> <h3> Calendar VisibleMonthChanged Example </h3> Select a different month on the calendar. <br><br> <asp:Calendar id="Calendar1" runat="server"> <WeekendDayStyle BackColor="gray"> </WeekendDayStyle> </asp:Calendar> <hr> <table border="1"> <tr bgcolor="Silver"> <th> Month navigation direction </th> </tr> <tr> <td> <asp:Label id="Message" Text="Starting Month." runat="server"/> </td> </tr> </table> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void MonthChange(Object sender, MonthChangedEventArgs e) { if (e.NewDate.Month > e.PreviousDate.Month) { Message.Text = "You moved forward one month."; } else { Message.Text = "You moved backwards one month."; } } void Page_Load(Object sender, EventArgs e) { // Manually register the event-handling method for the // VisibleMonthChanged event of the Calendar control. Calendar1.VisibleMonthChanged += new MonthChangedEventHandler(this.MonthChange); } </script> </head> <body> <form runat="server"> <h3> Calendar VisibleMonthChanged Example </h3> Select a different month on the calendar. <br><br> <asp:Calendar id="Calendar1" runat="server"> <WeekendDayStyle BackColor="gray"> </WeekendDayStyle> </asp:Calendar> <hr> <table border="1"> <tr bgcolor="Silver"> <th> Month navigation direction </th> </tr> <tr> <td> <asp:Label id="Message" Text="Starting month." runat="server"/> </td> </tr> </table> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMonthChangedEventHandler デリゲートを検索する場合は、下記のリンクをクリックしてください。

- MonthChangedEventHandler デリゲートのページへのリンク