Version

ValidateAppointment Event

Fired before changes made to an Appointment from within the AppointmentDialog are committed.
Syntax
'Declaration
 
Public Event ValidateAppointment As ValidateAppointmentEventHandler
public event ValidateAppointmentEventHandler ValidateAppointment
Event Data

The event handler receives an argument of type ValidateAppointmentEventArgs containing data related to this event. The following ValidateAppointmentEventArgs properties provide information specific to this event.

PropertyDescription
Appointment Returns a cloned appointment contained the updated information entered by the user via the AppointmentDialog.
CloseDialog Indicates whether the dialog should be closed.
Message Gets/sets the descriptive message that will be displayed to the end user.
OriginalAppointment Returns the original Appointment object or null if this is a new Appointment.
SaveChanges Indicates whether the changes should be saved.
Remarks

The ValidateAppointment is invoked when the user attempts to save the changes made to an appointment via the AppointmentDialog. The ValidateAppointmentEventArgs.Appointment may be updated to change the data that will be save or the save can be cancelled by setting the ValidateAppointmentEventArgs.SaveChanges to false.

Example
This example uses the ValidateAppointmentEventArgs' SaveChanges property to conditionally allow or disallow changes to the appointment; it uses the CloseDialog property to keep the dialog open until a certain condition is met, and it uses the OriginalAppointment property to inform the end user of the changes that have been made to the appointment.

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_ValidateAppointment(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.ValidateAppointmentEventArgs) Handles ultraCalendarInfo1.ValidateAppointment

        '----------------------------------------------------------------------------------------------------
        '	Description
        '	ValidateAppointment
        '
        '	Fires when an Appointment object is modified via the Appointment dialog
        '
        '----------------------------------------------------------------------------------------------------

        '	The SaveChanges property can be used to conditionally allow
        '	changes to be made to the appointment
        If (Not e.Appointment.Tag Is Nothing) Then

            Dim userID As String = e.Appointment.Tag

            '	If the user is not an administrator, don't save changes
            If (userID.ToLower() <> "admin") Then

                MessageBox.Show("You must have administrator rights to modify this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error)
                e.SaveChanges = False
                Return
            End If
        End If

        '	The CloseDialog property can be used to keep the dialog
        '	open until the state of the Appointment object meets
        '	certain requirements
        If (e.Appointment.Description Is Nothing Or e.Appointment.Description.Length = 0) Then

            MessageBox.Show("You must enter a Description for this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error)
            e.CloseDialog = False
            Return
        End If

        '	The OriginalAppointment property can be used to determine what changes,
        '	if any, were made to the appointment object
        Dim info As String = String.Empty
        If (e.OriginalAppointment.StartDateTime <> e.Appointment.StartDateTime) Then
            info += "The appointment's StartDateTime has changed." + vbCrLf
        End If
        If (e.OriginalAppointment.EndDateTime <> e.Appointment.EndDateTime) Then
            info += "The appointment's EndDateTime has changed." + vbCrLf
        End If

        If (e.OriginalAppointment.Subject <> e.Appointment.Subject) Then
            info += "The appointment's Subject has changed." + vbCrLf
        End If

        If (e.OriginalAppointment.Location <> e.Appointment.Location) Then
            info += "The appointment's Location has changed." + vbCrLf
        End If

        If (e.OriginalAppointment.Description <> e.Appointment.Description) Then
            info += "The appointment's Description has changed." + vbCrLf
        End If

        '	If any of the properties we are concerned with changed, notify the end user
        If (info.Length > 0) Then
            MessageBox.Show(info, "ValidateAppointment", MessageBoxButtons.OK)
        End If

    End Sub
using System.Diagnostics;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;

		private void ultraCalendarInfo1_ValidateAppointment(object sender, Infragistics.Win.UltraWinSchedule.ValidateAppointmentEventArgs e)
		{

			//----------------------------------------------------------------------------------------------------
			//	Description
			//	ValidateAppointment
			//
			//	Fires when an Appointment object is modified via the Appointment dialog
			//
			//----------------------------------------------------------------------------------------------------
			
			//	The SaveChanges property can be used to conditionally allow
			//	changes to be made to the appointment
			if ( e.Appointment.Tag is string )
			{
				string userID = e.Appointment.Tag as string;

				//	If the user is not an administrator, don't save changes
				if ( userID.ToLower() != "admin" )
				{
					MessageBox.Show( "You must have administrator rights to modify this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error );
					e.SaveChanges = false;
					return;
				}
			}

			//	The CloseDialog property can be used to keep the dialog
			//	open until the state of the Appointment object meets
			//	certain requirements
			if ( e.Appointment.Description == null ||
				 e.Appointment.Description.Length == 0 )
			{
				MessageBox.Show( "You must enter a Description for this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error );
				e.CloseDialog = false;
				return;
			}
				 
			//	The OriginalAppointment property can be used to determine what changes,
			//	if any, were made to the appointment object
			string info = string.Empty;
			if ( e.OriginalAppointment.StartDateTime != e.Appointment.StartDateTime)
				info += "The appointment's StartDateTime has changed." + "\n";

			if ( e.OriginalAppointment.EndDateTime != e.Appointment.EndDateTime)
				info += "The appointment's EndDateTime has changed." + "\n";

			if ( e.OriginalAppointment.Subject != e.Appointment.Subject )
				info += "The appointment's Subject has changed." + "\n";

			if ( e.OriginalAppointment.Location != e.Appointment.Location )
				info += "The appointment's Location has changed." + "\n";

			if ( e.OriginalAppointment.Description != e.Appointment.Description )
				info += "The appointment's Description has changed." + "\n";

			//	If any of the properties we are concerned with changed, notify the end user
			if ( info.Length > 0 )
				MessageBox.Show( info, "ValidateAppointment", MessageBoxButtons.OK );

		}
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