'Declaration Public Event BeforeSelectedHolidaysChange As BeforeSelectedHolidaysChangeEventHandler
public event BeforeSelectedHolidaysChangeEventHandler BeforeSelectedHolidaysChange
The event handler receives an argument of type BeforeSelectedHolidaysEventArgs containing data related to this event. The following BeforeSelectedHolidaysEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Cancel (Inherited from System.ComponentModel.CancelEventArgs) | |
NewSelectedHolidays | Returns a SelectedHolidaysCollection object containing the Holidays that will be selected if the event is not cancelled. The property is read-only. |
The BeforeSelectedHolidaysChange event may be canceled using System.ComponentModel.CancelEventArgs.Cancel property to prevent the SelectedHolidays collection from changing.
The BeforeSelectedHolidaysEventArgs.NewSelectedHolidays property returns a collection of the new selected Holiday objects.
While the event is being invoked, the SelectedHolidays collection cannot be modified. However, the collection returned from the BeforeSelectedHolidaysEventArgs.NewSelectedHolidays property may be modified.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics Private Sub ultraCalendarInfo1_BeforeSelectedHolidaysChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeSelectedHolidaysEventArgs) Handles ultraCalendarInfo1.BeforeSelectedHolidaysChange '---------------------------------------------------------------------------------------------------- ' Description ' BeforeSelectedHolidaysChange ' ' Fires after one or more Holiday(s) are selected or deselected. ' '---------------------------------------------------------------------------------------------------- ' If the count of the NewSelectedHolidays collection is greater than ' the count of the existing SelectedHolidays collection, then new ' Holidays have been selected Dim info As String = String.Empty If (e.NewSelectedHolidays.Count > Me.ultraCalendarInfo1.SelectedHolidays.Count) Then info += "The following Holidays have been added to the selection:" + vbCrLf + vbCrLf If (Me.ultraCalendarInfo1.SelectedHolidays.Count > 0) Then ' Iterate the NewSelectedHolidays collection and get information on ' each new selection Dim newHoliday As Holiday For Each newHoliday In e.NewSelectedHolidays ' Iterate the existing selected Holidays, and see which ones are new ' to the collection Dim oldHoliday As Holiday For Each oldHoliday In Me.ultraCalendarInfo1.SelectedHolidays If (newHoliday Is oldHoliday) Then Exit For Else ' If the existing Holiday exists in the SelectedHolidays collection, ' then it is not really new to the user, so we won't list it as new. info += newHoliday.Name + " (" info += newHoliday.StartDate.ToLongDateString() + ")" + vbCrLf End If Next Next Else ' The count of the SelectedHolidays collection was zero, so we don't ' have to check to see whether they already existed, just list them all Dim newHoliday As Holiday For Each newHoliday In e.NewSelectedHolidays ' If the existing Holiday exists in the SelectedHolidays collection, ' but not in the NewSelectedHolidays collection, it has been deselected info += newHoliday.Name + " (" info += newHoliday.StartDate.ToLongDateString() + ")" + vbCrLf Next End If ElseIf (e.NewSelectedHolidays.Count > 0) Then ' Otherwise, one or more existing Holidays have been deselected info += "The following Holidays have been removed from the selection:" + vbCrLf + vbCrLf ' Iterate the existing SelectedHolidays collection and get information on ' each selection that is being removed Dim oldHoliday As Holiday For Each oldHoliday In Me.ultraCalendarInfo1.SelectedHolidays ' Iterate the existing selected Holidays, and see which ones are new ' to the collection Dim newHoliday As Holiday For Each newHoliday In e.NewSelectedHolidays If (newHoliday Is oldHoliday) Then Exit For Else ' If the existing Holiday exists in the SelectedHolidays collection, ' but not in the NewSelectedHolidays collection, it has been deselected info += oldHoliday.Name + " (" info += oldHoliday.StartDate.ToLongDateString() + ")" + vbCrLf End If Next Next Else ' The selection has been cleared info += "The SelectedHolidays collection is about to be cleared." + vbCrLf info += vbCrLf + vbCrLf + "Continue?" ' Display a MessageBox and prompt the end user to make sure they want to continue Dim result As DialogResult = MessageBox.Show(info, "BeforeSelectedHolidaysChange", MessageBoxButtons.YesNo) ' If the user does not want to continue, cancel the event If (result = DialogResult.No) Then e.Cancel = True End If End Sub
private void ultraCalendarInfo1_BeforeSelectedHolidaysChange(object sender, Infragistics.Win.UltraWinSchedule.BeforeSelectedHolidaysEventArgs e) { //---------------------------------------------------------------------------------------------------- // Description // BeforeSelectedHolidaysChange // // Fires after one or more Holiday(s) are selected or deselected. // //---------------------------------------------------------------------------------------------------- // If the count of the NewSelectedHolidays collection is greater than // the count of the existing SelectedHolidays collection, then new // Holidays have been selected string info = string.Empty; if ( e.NewSelectedHolidays.Count > this.ultraCalendarInfo1.SelectedHolidays.Count ) { info += "The following Holidays have been added to the selection:" + "\n\n"; if ( this.ultraCalendarInfo1.SelectedHolidays.Count > 0 ) { // Iterate the NewSelectedHolidays collection and get information on // each new selection foreach( Holiday newHoliday in e.NewSelectedHolidays ) { // Iterate the existing selected Holidays, and see which ones are new // to the collection foreach( Holiday oldHoliday in this.ultraCalendarInfo1.SelectedHolidays ) { if ( newHoliday == oldHoliday ) continue; else { // If the existing Holiday exists in the SelectedHolidays collection, // then it is not really new to the user, so we won't list it as new. info += newHoliday.Name + " ("; info += newHoliday.StartDate.ToLongDateString() + ")" + "\n"; } } } } else { // The count of the SelectedHolidays collection was zero, so we don't // have to check to see whether they already existed, just list them all foreach( Holiday newHoliday in e.NewSelectedHolidays ) { info += newHoliday.Name + " ("; info += newHoliday.StartDate.ToLongDateString() + ")" + "\n"; } } } else if ( e.NewSelectedHolidays.Count > 0 ) { // Otherwise, one or more existing Holidays have been deselected info += "The following Holidays have been removed from the selection:" + "\n\n"; // Iterate the existing SelectedHolidays collection and get information on // each selection that is being removed foreach( Holiday oldHoliday in this.ultraCalendarInfo1.SelectedHolidays ) { // Iterate the existing selected Holidays, and see which ones are new // to the collection foreach( Holiday newHoliday in e.NewSelectedHolidays ) { if ( newHoliday == oldHoliday ) continue; else { // If the existing Holiday exists in the SelectedHolidays collection, // but not in the NewSelectedHolidays collection, it has been deselected info += newHoliday.Name + " ("; info += newHoliday.StartDate.ToLongDateString() + ")" + "\n"; } } } } else { // The selection has been cleared info += "The SelectedHolidays collection is about to be cleared." + "\n"; } info += "\n\n" + "Continue?"; // Display a MessageBox and prompt the end user to make sure they want to continue DialogResult result = MessageBox.Show( info, "BeforeSelectedHolidaysChange", MessageBoxButtons.YesNo ); // If the user does not want to continue, cancel the event 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