Delegate for handling the event that occurs after the ActiveDay is changed.
This example displays information about the new active day after it changes.
For an overview of how to handle events in Visual Basic or Visual C#, see
Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see
Consuming Events in the
.NET Framework Developer's Guide.
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics
Private Sub ultraCalendarInfo1_AfterActiveDayChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.AfterActiveDayChangedEventArgs) Handles ultraCalendarInfo1.AfterActiveDayChanged
'----------------------------------------------------------------------------------------------------
' Description
' AfterActiveDayChanged
'
' Fires after the component's 'ActiveDay' changes.
' The ActiveDay can be thought of as the day with "focus" in
' that there is only one active day at any given time.
'
'----------------------------------------------------------------------------------------------------
Dim info As String = String.Empty
' Get the date of the new ActiveDay
info += "The date of the new ActiveDay is " + e.Day.Date.ToLongDateString() + vbCrLf
' Get the day of the week of the new ActiveDay
info += "The new ActiveDay falls on a " + e.Day.DayOfWeek.DayOfTheWeek.ToString() + vbCrLf
' Get the number of the week of the ActiveDay
info += "The new ActiveDay falls in week number " + e.Day.Week.WeekNumber.ToString() + " of the year.\n"
' Get the number of the day in its month, and the name of the month
Dim monthName As String = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames(e.Day.Month.MonthNumber - 1)
info += "The new ActiveDay is day number " + e.Day.DayNumber.ToString()
info += " in the month of " + monthName + vbCrLf
' Get approximately how far into the month the ActiveDay is
Dim daysInMonth As Integer = e.Day.Month.DaysInMonth
Dim elapsed As Double = e.Day.DayNumber / daysInMonth
elapsed *= 100
info += "The new ActiveDay is approximately " + elapsed.ToString("n") + "% of the way into the month." + vbCrLf
' Get the number of the year
info += "The new ActiveDay is in the year " + e.Day.Month.Year.YearNumber.ToString() + vbCrLf
' Get approximately how far into the year the ActiveDay is
Dim daysInYear As Integer = 365
If e.Day.Month.Year.IsLeapYear Then daysInYear = 366
elapsed = e.Day.DayOfYear / daysInYear
elapsed *= 100
info += "The new ActiveDay is approximately " + elapsed.ToString("n") + "% of the way into the year." + vbCrLf
' If there is activity, display the number of each type
If e.Day.HasActivity Then
Dim activity As String = String.Empty
If (e.Day.Appointments.Count > 0) Then activity += e.Day.Appointments.Count.ToString() + " Appointment(s)" + vbCrLf
If (e.Day.Holidays.Count > 0) Then activity += e.Day.Holidays.Count.ToString() + " Holiday(s)" + vbCrLf
If (e.Day.Notes.Count > 0) Then activity += e.Day.Notes.Count.ToString() + " Note(s)" + vbCrLf
info += "There is activity for the new ActiveDay :" + vbCrLf + vbCrLf
info += activity + vbCrLf
End If
' Display whether the day is enabled
If (e.Day.Enabled) Then
info += "The new ActiveDay is enabled." + vbCrLf
Else
info += "The new ActiveDay is disabled." + vbCrLf
End If
' Display whether the day is selected
If (e.Day.Selected) Then
info += "The new ActiveDay is selected." + vbCrLf
' Display the information
MessageBox.Show(info, "ActiveDay information")
End If
End Sub
using System.Diagnostics;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
private void ultraCalendarInfo1_AfterActiveDayChanged(object sender, Infragistics.Win.UltraWinSchedule.AfterActiveDayChangedEventArgs e)
{
//----------------------------------------------------------------------------------------------------
// Description
// AfterActiveDayChanged
//
// Fires after the component's 'ActiveDay' changes.
// The ActiveDay can be thought of as the day with "focus" in
// that there is only one active day at any given time.
//
//----------------------------------------------------------------------------------------------------
string info = string.Empty;
// Get the date of the new ActiveDay
info += "The date of the new ActiveDay is " + e.Day.Date.ToLongDateString() + ".\n";
// Get the day of the week of the new ActiveDay
info += "The new ActiveDay falls on a " + e.Day.DayOfWeek.DayOfTheWeek.ToString() + ".\n";
// Get the number of the week of the ActiveDay
info += "The new ActiveDay falls in week number " + e.Day.Week.WeekNumber.ToString() + " of the year.\n";
// Get the number of the day in its month, and the name of the month
string monthName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[ e.Day.Month.MonthNumber -1 ];
info += "The new ActiveDay is day number " + e.Day.DayNumber.ToString();
info += " in the month of " + monthName + ".\n";
// Get approximately how far into the month the ActiveDay is
int daysInMonth = e.Day.Month.DaysInMonth;
double elapsed = (double)(e.Day.DayNumber) / (double)(daysInMonth);
elapsed *= 100;
info += "The new ActiveDay is approximately " + elapsed.ToString("n") + "% of the way into the month.\n";
// Get the number of the year
info += "The new ActiveDay is in the year " + e.Day.Month.Year.YearNumber.ToString() + ".\n";
// Get approximately how far into the year the ActiveDay is
int daysInYear = e.Day.Month.Year.IsLeapYear ? 366 : 365;
elapsed = (double)(e.Day.DayOfYear) / (double)(daysInYear);
elapsed *= 100;
info += "The new ActiveDay is approximately " + elapsed.ToString("n") + "% of the way into the year.\n";
// If there is activity, display the number of each type
if ( e.Day.HasActivity )
{
string activity = string.Empty;
if ( e.Day.Appointments.Count > 0 )
activity += e.Day.Appointments.Count.ToString() + " Appointment(s)\n";
if ( e.Day.Holidays.Count > 0 )
activity += e.Day.Holidays.Count.ToString() + " Holiday(s)\n";
if ( e.Day.Notes.Count > 0 )
activity += e.Day.Notes.Count.ToString() + " Note(s)\n";
info += "There is activity for the new ActiveDay :\n\n";
info += activity + "\n";
}
// Display whether the day is enabled
if ( e.Day.Enabled )
info += "The new ActiveDay is enabled.\n";
else
info += "The new ActiveDay is disabled.\n";
// Display whether the day is selected
if ( e.Day.Selected )
info += "The new ActiveDay is selected.\n";
// Display the information
MessageBox.Show( info, "ActiveDay information" );
}
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2