Version

OnBeforeActiveDayChanged Method

Raises the BeforeActiveDayChanged event before the ActiveDay is changed.
Syntax
'Declaration
 
Protected Overridable Sub OnBeforeActiveDayChanged( _
   ByVal e As BeforeActiveDayChangedEventArgs _
) 
protected virtual void OnBeforeActiveDayChanged( 
   BeforeActiveDayChangedEventArgs e
)

Parameters

e
A BeforeActiveDayChangedEventArgs that provides data for the event.
Remarks

Raising an event invokes the event handler through a delegate.

The OnBeforeActiveDayChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Notes to Inheritors: When overriding OnBeforeActiveDayChanged in a derived class, be sure to call the base class's OnBeforeActiveDayChanged method so that registered delegates receive the event.

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