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 ); } }
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