Version

CancelableHolidayEventHandler Delegate

Delegate for handling the Cancelable event involving a single Holiday object.
Syntax
'Declaration
 
Public Delegate Sub CancelableHolidayEventHandler( _
   ByVal sender As Object, _
   ByVal e As CancelableHolidayEventArgs _
) 
public delegate void CancelableHolidayEventHandler( 
   object sender,
   CancelableHolidayEventArgs e
)

Parameters

sender
e
Example
This example uses the CancelableHolidayEventArgs' Cancel property to disallow the addition of Holidays in months that already have one.

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_BeforeHolidayAdded(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.CancelableHolidayEventArgs) Handles ultraCalendarInfo1.BeforeHolidayAdded

        '----------------------------------------------------------------------------------------------------
        '	Description
        '	BeforeHolidayAdded
        '
        '	Fires before a new holiday is added to the component's Holidays collection.
        '	If canceled, the Holiday is not added, and the AfterHolidayAdded event does not fire.
        '
        '----------------------------------------------------------------------------------------------------

        '	Determine whether the month for which this holiday is being added
        '	has any existing holidays

        If (e.Holiday.Day.Month.Holidays.Count > 0) Then
            '	To prevent the addition of the Holiday, set the Cancel
            '	property to true
            e.Cancel = True

            '	Let the end user know what happened
            Dim info As String = String.Empty
            Dim monthName As String = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames(e.Holiday.Day.Month.MonthNumber - 1)
            info += "Sorry, but there is already a Holiday for the month of " + monthName + "."

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

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

		private void ultraCalendarInfo1_BeforeHolidayAdded(object sender, Infragistics.Win.UltraWinSchedule.CancelableHolidayEventArgs e)
		{		

			//----------------------------------------------------------------------------------------------------
			//	Description
			//	BeforeHolidayAdded
			//
			//	Fires before a new holiday is added to the component's Holidays collection.
			//	If canceled, the Holiday is not added, and the AfterHolidayAdded event does not fire.
			//
			//----------------------------------------------------------------------------------------------------

			//	Determine whether the month for which this holiday is being added
			//	has any existing holidays

			if ( e.Holiday.Day.Month.Holidays.Count > 0 )
			{
				//	To prevent the addition of the Holiday, set the Cancel
				//	property to true
				e.Cancel = true;

				//	Let the end user know what happened
				string info = string.Empty;
				string monthName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[ e.Holiday.Day.Month.MonthNumber -1 ];
				info += "Sorry, but there is already a Holiday for the month of " + monthName + ".";

				MessageBox.Show( info, "BeforeHolidayAdded", 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