Version

BeforeActiveDayChangedEventHandler Delegate

Delegate for handling the event that occurs before the ActiveDay is changed.
Syntax
'Declaration
 
Public Delegate Sub BeforeActiveDayChangedEventHandler( _
   ByVal sender As Object, _
   ByVal e As BeforeActiveDayChangedEventArgs _
) 
public delegate void BeforeActiveDayChangedEventHandler( 
   object sender,
   BeforeActiveDayChangedEventArgs e
)

Parameters

sender
e
Example
This example uses the BeforeActiveDayChangedEventArgs' Cancel property to disallow activation of weekend days.

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_BeforeActiveDayChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeActiveDayChangedEventArgs) Handles ultraCalendarInfo1.BeforeActiveDayChanged

        '----------------------------------------------------------------------------------------------------
        '	Description
        '	BeforeActiveDayChanged
        '
        '	Fires before the ActiveDay changes. If canceled, the ActiveDay does not change, and the
        '	AfterActiveDayChanged event does not fire.
        '
        '----------------------------------------------------------------------------------------------------

        '	Get the day of the week of what will become the new ActiveDay
        Dim DayOfWeek As System.DayOfWeek = e.Day.Date.DayOfWeek

        '	See if new ActiveDay falls on a Saturday or a Sunday
        If (DayOfWeek = System.DayOfWeek.Saturday Or DayOfWeek = System.DayOfWeek.Sunday) Then
            '	To prevent activation of weekend days, set the Cancel
            '	property to true
            e.Cancel = True

            '	Let the end user know what happened
            Dim info As String = String.Empty
            info += "You cannot activate " + e.Day.Date.ToLongDateString() + " because it falls on a "
            info += DayOfWeek.ToString()

            MessageBox.Show(info, "BeforeActiveDayChanged", MessageBoxButtons.OK)
        End If

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

		private void ultraCalendarInfo1_BeforeActiveDayChanged(object sender, Infragistics.Win.UltraWinSchedule.BeforeActiveDayChangedEventArgs e)
		{

			//----------------------------------------------------------------------------------------------------
			//	Description
			//	BeforeActiveDayChanged
			//
			//	Fires before the ActiveDay changes. If canceled, the ActiveDay does not change, and the
			//	AfterActiveDayChanged event does not fire.
			//
			//----------------------------------------------------------------------------------------------------
		
			//	Get the day of the week of what will become the new ActiveDay
			System.DayOfWeek dayOfWeek = e.Day.Date.DayOfWeek;

			//	See if new ActiveDay falls on a Saturday or a Sunday
			if ( dayOfWeek == System.DayOfWeek.Saturday ||
				 dayOfWeek == System.DayOfWeek.Sunday )
			{
				//	To prevent activation of weekend days, set the Cancel
				//	property to true
				e.Cancel = true;

				//	Let the end user know what happened
				string info = string.Empty;
				info += "You cannot activate " + e.Day.Date.ToLongDateString() + " because it falls on a ";
				info += dayOfWeek.ToString();

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