'Declaration Protected Overridable Sub OnBeforeSelectedAppointmentsChange( _ ByVal e As BeforeSelectedAppointmentsEventArgs _ )
protected virtual void OnBeforeSelectedAppointmentsChange( BeforeSelectedAppointmentsEventArgs e )
Raising an event invokes the event handler through a delegate.
The OnBeforeSelectedAppointmentsChange method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Notes to Inheritors: When overriding OnBeforeSelectedAppointmentsChange in a derived class, be sure to call the base class's OnBeforeSelectedAppointmentsChange method so that registered delegates receive the event.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics Private Sub ultraCalendarInfo1_BeforeSelectedAppointmentsChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeSelectedAppointmentsEventArgs) Handles ultraCalendarInfo1.BeforeSelectedAppointmentsChange '---------------------------------------------------------------------------------------------------- ' Description ' BeforeSelectedAppointmentsChange ' ' Fires before one or more Appointment(s) are selected or deselected. ' '---------------------------------------------------------------------------------------------------- ' If the count of the NewSelectedAppointments collection is greater than ' the count of the existing SelectedAppointments collection, then new ' appointments have been selected Dim info As String = String.Empty If (e.NewSelectedAppointments.Count > Me.ultraCalendarInfo1.SelectedAppointments.Count) Then info += "The following appointments have been added to the selection:" + vbCrLf + vbCrLf If (Me.ultraCalendarInfo1.SelectedAppointments.Count > 0) Then ' Iterate the NewSelectedAppointments collection and get information on ' each new selection Dim newAppointment As Appointment For Each newAppointment In e.NewSelectedAppointments ' Iterate the existing selected appointments, and see which ones are new ' to the collection Dim oldAppointment As Appointment For Each oldAppointment In Me.ultraCalendarInfo1.SelectedAppointments If (newAppointment Is oldAppointment) Then Exit For Else ' If the existing appointment exists in the SelectedAppointments collection, ' then it is not really new to the user, so we won't list it as new. info += newAppointment.Subject + " (" info += newAppointment.StartDateTime.ToLongDateString() + ")" + vbCrLf End If Next Next Else ' The count of the SelectedAppointments collection was zero, so we don't ' have to check to see whether they already existed, just list them all Dim newAppointment As Appointment For Each newAppointment In e.NewSelectedAppointments ' If the existing appointment exists in the SelectedAppointments collection, ' but not in the NewSelectedAppointments collection, it has been deselected info += newAppointment.Subject + " (" info += newAppointment.StartDateTime.ToLongDateString() + ")" + vbCrLf Next End If ElseIf (e.NewSelectedAppointments.Count > 0) Then ' Otherwise, one or more existing appointments have been deselected info += "The following appointments have been removed from the selection:" + vbCrLf + vbCrLf ' Iterate the existing SelectedAppointments collection and get information on ' each selection that is being removed Dim oldAppointment As Appointment For Each oldAppointment In Me.ultraCalendarInfo1.SelectedAppointments ' Iterate the existing selected appointments, and see which ones are new ' to the collection Dim newAppointment As Appointment For Each newAppointment In e.NewSelectedAppointments If (newAppointment Is oldAppointment) Then Exit For Else ' If the existing appointment exists in the SelectedAppointments collection, ' but not in the NewSelectedAppointments collection, it has been deselected info += oldAppointment.Subject + " (" info += oldAppointment.StartDateTime.ToLongDateString() + ")" + vbCrLf End If Next Next Else ' The selection has been cleared info += "The SelectedAppointments 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, "BeforeSelectedAppointmentsChange", 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
using System.Diagnostics; using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; private void ultraCalendarInfo1_BeforeSelectedAppointmentsChange(object sender, Infragistics.Win.UltraWinSchedule.BeforeSelectedAppointmentsEventArgs e) { //---------------------------------------------------------------------------------------------------- // Description // BeforeSelectedAppointmentsChange // // Fires before one or more Appointment(s) are selected or deselected. // //---------------------------------------------------------------------------------------------------- // If the count of the NewSelectedAppointments collection is greater than // the count of the existing SelectedAppointments collection, then new // appointments have been selected string info = string.Empty; if ( e.NewSelectedAppointments.Count > this.ultraCalendarInfo1.SelectedAppointments.Count ) { info += "The following appointments have been added to the selection:" + "\n\n"; if ( this.ultraCalendarInfo1.SelectedAppointments.Count > 0 ) { // Iterate the NewSelectedAppointments collection and get information on // each new selection foreach( Appointment newAppointment in e.NewSelectedAppointments ) { // Iterate the existing selected appointments, and see which ones are new // to the collection foreach( Appointment oldAppointment in this.ultraCalendarInfo1.SelectedAppointments ) { if ( newAppointment == oldAppointment ) break; else { // If the existing appointment exists in the SelectedAppointments collection, // then it is not really new to the user, so we won't list it as new. info += newAppointment.Subject + " ("; info += newAppointment.StartDateTime.ToLongDateString() + ")" + "\n"; } } } } else { // The count of the SelectedAppointments collection was zero, so we don't // have to check to see whether they already existed, just list them all foreach( Appointment newAppointment in e.NewSelectedAppointments ) { // If the existing appointment exists in the SelectedAppointments collection, // but not in the NewSelectedAppointments collection, it has been deselected info += newAppointment.Subject + " ("; info += newAppointment.StartDateTime.ToLongDateString() + ")" + "\n"; } } } else if ( e.NewSelectedAppointments.Count > 0 ) { // Otherwise, one or more existing appointments have been deselected info += "The following appointments have been removed from the selection:" + "\n\n"; // Iterate the existing SelectedAppointments collection and get information on // each selection that is being removed foreach( Appointment oldAppointment in this.ultraCalendarInfo1.SelectedAppointments ) { // Iterate the existing selected appointments, and see which ones are new // to the collection foreach( Appointment newAppointment in e.NewSelectedAppointments ) { if ( newAppointment == oldAppointment ) break; else { // If the existing appointment exists in the SelectedAppointments collection, // but not in the NewSelectedAppointments collection, it has been deselected info += oldAppointment.Subject + " ("; info += oldAppointment.StartDateTime.ToLongDateString() + ")" + "\n"; } } } } else { // The selection has been cleared info += "The SelectedAppointments 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, "BeforeSelectedAppointmentsChange", 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