Version

BeforeSelectedNotesEventArgs Class

Event parameters for the UltraCalendarInfo.BeforeSelectedNotesChange event.
Syntax
'Declaration
 
Public Class BeforeSelectedNotesEventArgs 
   Inherits System.ComponentModel.CancelEventArgs
public class BeforeSelectedNotesEventArgs : System.ComponentModel.CancelEventArgs 
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_BeforeSelectedNotesChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeSelectedNotesEventArgs) Handles ultraCalendarInfo1.BeforeSelectedNotesChange

        '----------------------------------------------------------------------------------------------------
        '	Description
        '	BeforeSelectedNotesChange
        '
        '	Fires after one or more Note(s) are selected or deselected.
        '
        '----------------------------------------------------------------------------------------------------

        '	If the count of the NewSelectedNotes collection is greater than
        '	the count of the existing SelectedNotes collection, then new
        '	Notes have been selected
        Dim info As String = String.Empty
        If (e.NewSelectedNotes.Count > Me.ultraCalendarInfo1.SelectedNotes.Count) Then
            info += "The following Notes have been added to the selection:" + vbCrLf + vbCrLf

            If (Me.ultraCalendarInfo1.SelectedNotes.Count > 0) Then
                '	Iterate the NewSelectedNotes collection and get information on
                '	each new selection
                Dim newNote As Note
                For Each newNote In e.NewSelectedNotes

                    '	Iterate the existing selected Notes, and see which ones are new
                    '	to the collection
                    Dim oldNote As Note
                    For Each oldNote In Me.ultraCalendarInfo1.SelectedNotes
                        If (newNote Is oldNote) Then
                            Exit For
                        Else

                            '	If the existing Note exists in the SelectedNotes collection,
                            '	then it is not really new to the user, so we won't list it as new.
                            info += newNote.Description + " ("
                            info += newNote.Date.ToLongDateString() + ")" + vbCrLf
                        End If

                    Next
                Next

            Else
                '	The count of the SelectedNotes collection was zero, so we don't
                '	have to check to see whether they already existed, just list them all
                Dim newNote As Note
                For Each newNote In e.NewSelectedNotes
                    '	If the existing Note exists in the SelectedNotes collection,
                    '	but not in the NewSelectedNotes collection, it has been deselected
                    info += newNote.Description + " ("
                    info += newNote.Date.ToLongDateString() + ")" + vbCrLf
                Next
            End If
        ElseIf (e.NewSelectedNotes.Count > 0) Then

            '	Otherwise, one or more existing Notes have been deselected
            info += "The following Notes have been removed from the selection:" + vbCrLf + vbCrLf

            '	Iterate the existing SelectedNotes collection and get information on
            '	each selection that is being removed
            Dim oldNote As Note
            For Each oldNote In Me.ultraCalendarInfo1.SelectedNotes
                '	Iterate the existing selected Notes, and see which ones are new
                '	to the collection
                Dim newNote As Note
                For Each newNote In e.NewSelectedNotes
                    If (newNote Is oldNote) Then
                        Exit For
                    Else

                        '	If the existing Note exists in the SelectedNotes collection,
                        '	but not in the NewSelectedNotes collection, it has been deselected
                        info += oldNote.Description + " ("
                        info += oldNote.Date.ToLongDateString() + ")" + vbCrLf
                    End If
                Next

            Next
        Else
            '	The selection has been cleared
            info += "The SelectedNotes 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, "BeforeSelectedNotesChange", 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_BeforeSelectedNotesChange(object sender, Infragistics.Win.UltraWinSchedule.BeforeSelectedNotesEventArgs e)
		{
		
			//----------------------------------------------------------------------------------------------------
			//	Description
			//	BeforeSelectedNotesChange
			//
			//	Fires after one or more Note(s) are selected or deselected.
			//
			//----------------------------------------------------------------------------------------------------

			//	If the count of the NewSelectedNotes collection is greater than
			//	the count of the existing SelectedNotes collection, then new
			//	Notes have been selected
			string info = string.Empty;
			if ( e.NewSelectedNotes.Count > this.ultraCalendarInfo1.SelectedNotes.Count )
			{
				info += "The following Notes have been added to the selection:" + "\n\n";

				if ( this.ultraCalendarInfo1.SelectedNotes.Count > 0 )
				{
					//	Iterate the NewSelectedNotes collection and get information on
					//	each new selection
					foreach( Note newNote in e.NewSelectedNotes )
					{
						//	Iterate the existing selected Notes, and see which ones are new
						//	to the collection
						foreach( Note oldNote in this.ultraCalendarInfo1.SelectedNotes )
						{
							if ( newNote == oldNote )
								continue;
							else
							{
								//	If the existing Note exists in the SelectedNotes collection,
								//	then it is not really new to the user, so we won't list it as new.
								info += newNote.Description + " (";
								info += newNote.Date.ToLongDateString() + ")" + "\n";
							}
						}
						
					}
				}
				else
				{
					//	The count of the SelectedNotes collection was zero, so we don't
					//	have to check to see whether they already existed, just list them all
					foreach( Note newNote in e.NewSelectedNotes )
					{
						info += newNote.Description + " (";
						info += newNote.Date.ToLongDateString() + ")" + "\n";
					}
				}
			}
			else
			if ( e.NewSelectedNotes.Count > 0 )
			{
				//	Otherwise, one or more existing Notes have been deselected
				info += "The following Notes have been removed from the selection:" + "\n\n";

				//	Iterate the existing SelectedNotes collection and get information on
				//	each selection that is being removed
				foreach( Note oldNote in this.ultraCalendarInfo1.SelectedNotes )
				{
					//	Iterate the existing selected Notes, and see which ones are new
					//	to the collection
					foreach( Note newNote in e.NewSelectedNotes )
					{
						if ( newNote == oldNote )
							continue;
						else
						{
							//	If the existing Note exists in the SelectedNotes collection,
							//	but not in the NewSelectedNotes collection, it has been deselected
							info += newNote.Description + " (";
							info += newNote.Date.ToLongDateString() + ")" + "\n";
						}

					}
					
				}
			}
			else
			{
				//	The selection has been cleared
				info += "The SelectedNotes 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, "BeforeSelectedNotesChange", 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