Version

SelectedAppointments Property (UltraCalendarInfo)

Returns the collection of selected Appointment objects.
Syntax
'Declaration
 
Public ReadOnly Property SelectedAppointments As SelectedAppointmentsCollection
public SelectedAppointmentsCollection SelectedAppointments {get;}
Example
This example compares the old selection to the new selection and displays information to the end user about what has changed. It then prompts to see if they want to continue with the new selection.

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_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;

		}
Requirements

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

See Also