Version

BeforeAppointmentAdded Event

Fired before an Appointment is added to the Appointments collection.
Syntax
'Declaration
 
Public Event BeforeAppointmentAdded As CancelableAppointmentEventHandler
public event CancelableAppointmentEventHandler BeforeAppointmentAdded
Event Data

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

PropertyDescription
Appointment Returns the appointment object associated with the event. This property is read-only.
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Example
This example uses the CancelableAppointmentEventArgs' Cancel property to disallow the addition of Appointments to Mondays.

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_BeforeAppointmentAdded(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.CancelableAppointmentEventArgs) Handles ultraCalendarInfo1.BeforeAppointmentAdded

        '----------------------------------------------------------------------------------------------------
        '	Description
        '	BeforeAppointmentAdded
        '
        '	Fires before a new appointment is added to the component's Appointments collection.
        '	If canceled, the Appointment is not added, and the AfterAppointmentAdded event does not fire.
        '
        '----------------------------------------------------------------------------------------------------

        If (e.Appointment.StartDateTime.DayOfWeek = System.DayOfWeek.Monday) Then
            '	To prevent the addition of the Appointment, set the Cancel
            '	property to true
            e.Cancel = True

            '	Let the end user know what happened
            Dim info As String = String.Empty
            info += "Sorry, but we are no longer accepting new appointments on "
            info += e.Appointment.StartDateTime.DayOfWeek.ToString() + "s"

            MessageBox.Show(info, "BeforeAppointmentAdded", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        End If

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

		private void ultraCalendarInfo1_BeforeAppointmentAdded(object sender, Infragistics.Win.UltraWinSchedule.CancelableAppointmentEventArgs e)
		{		

			//----------------------------------------------------------------------------------------------------
			//	Description
			//	BeforeAppointmentAdded
			//
			//	Fires before a new appointment is added to the component's Appointments collection.
			//	If canceled, the Appointment is not added, and the AfterAppointmentAdded event does not fire.
			//
			//----------------------------------------------------------------------------------------------------

			if ( e.Appointment.StartDateTime.DayOfWeek == System.DayOfWeek.Monday )
			{
				//	To prevent the addition of the Appointment, set the Cancel
				//	property to true
				e.Cancel = true;

				//	Let the end user know what happened
				string info = string.Empty;
				info += "Sorry, but we are no longer accepting new appointments on ";
				info += e.Appointment.StartDateTime.DayOfWeek.ToString() + "s";

				MessageBox.Show( info, "BeforeAppointmentAdded", MessageBoxButtons.OK, MessageBoxIcon.Stop );
			}

		}
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