Version

ValidateAppointmentEventArgs Class

Event parameters for the ValidateAppointment event.
Syntax
'Declaration
 
Public Class ValidateAppointmentEventArgs 
   Inherits System.EventArgs
public class ValidateAppointmentEventArgs : System.EventArgs 
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