The actual number of Day objects that can be selected may be less depending on the SelectTypeDay. For example, if SelectTypeDay is set to SelectTypeSingle, only one day may be selected at a time.
This property cannot be modified while the BeforeSelectedDateRangeChange event is being invoked.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics Private Sub ultraCalendarInfo1_BeforeSelectedDateRangeChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeSelectedDateRangeChangeEventArgs) Handles ultraCalendarInfo1.BeforeSelectedDateRangeChange '---------------------------------------------------------------------------------------------------- ' Description ' BeforeSelectedDateRangeChange ' ' Fires before a range of days is selected or deselected. ' ' The SelectedDateRanges collection is actually a collection of collections, ' each "sub collection" representing the actual days that are selected. Each ' DateRange object represents a contiguous range of days that are all selected. ' When new days are selected, they are added to an existing DateRange object, ' if the new day is adjacent to a currently selected day. If it is not, a new DateRange ' object is added to the collection, which will at that point have only one day in it. ' '---------------------------------------------------------------------------------------------------- ' If the limit on the number of selected days has been reached, ' suppress the dialog, and up the limit by one If (e.WasMaxSelectedDaysExceeded) Then Me.ultraCalendarInfo1.MaxSelectedDays += 1 e.DisplayMaxSelectedDaysErrorMsg = False End If Dim range As Infragistics.Win.UltraWinSchedule.DateRange For Each range In e.NewSelectedDateRanges Dim day As Infragistics.Win.UltraWinSchedule.Day For Each day In range.Days If day.DayOfWeek.DayOfTheWeek = System.DayOfWeek.Saturday Or day.DayOfWeek.DayOfTheWeek = System.DayOfWeek.Sunday Then Dim info As String = "The new selection includes a weekend day." + vbCrLf info += "Continue?." + vbCrLf Dim result As DialogResult = MessageBox.Show(info, "BeforeSelectedDateRangeChange", MessageBoxButtons.YesNo) If (result = DialogResult.No) Then e.Cancel = True End If End If Next Next End Sub
using System.Diagnostics; using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; private void ultraCalendarInfo1_BeforeSelectedDateRangeChange(object sender, Infragistics.Win.UltraWinSchedule.BeforeSelectedDateRangeChangeEventArgs e) { //---------------------------------------------------------------------------------------------------- // Description // BeforeSelectedDateRangeChange // // Fires before a range of days is selected or deselected. // // The SelectedDateRanges collection is actually a collection of collections, // each "sub collection" representing the actual days that are selected. Each // DateRange object represents a contiguous range of days that are all selected. // When new days are selected, they are added to an existing DateRange object, // if the new day is adjacent to a currently selected day. If it is not, a new DateRange // object is added to the collection, which will at that point have only one day in it. // //---------------------------------------------------------------------------------------------------- // If the limit on the number of selected days has been reached, // suppress the dialog, and up the limit by one if ( e.WasMaxSelectedDaysExceeded ) { this.ultraCalendarInfo1.MaxSelectedDays++; e.DisplayMaxSelectedDaysErrorMsg = false; } foreach ( DateRange range in e.NewSelectedDateRanges ) { foreach( Infragistics.Win.UltraWinSchedule.Day day in range.Days ) { if ( (System.DayOfWeek)day.DayOfWeek.DayOfTheWeek == System.DayOfWeek.Saturday || (System.DayOfWeek)day.DayOfWeek.DayOfTheWeek == System.DayOfWeek.Sunday ) { string info = "The new selection includes a weekend day." + "\n"; info += "Continue?." + "\n"; DialogResult result = MessageBox.Show( info, "BeforeSelectedDateRangeChange", MessageBoxButtons.YesNo ); if ( result == DialogResult.No ) e.Cancel = true; } } } }
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