Version

DoesDateRangeHaveActivity(DateTime) Method

Indicates if the specified Date has any activity.
Syntax
'Declaration
 
Public Overloads Function DoesDateRangeHaveActivity( _
   ByVal startAndEndDate As Date _
) As Boolean
public bool DoesDateRangeHaveActivity( 
   DateTime startAndEndDate
)

Parameters

startAndEndDate
Date to check.

Return Value

True if there is any activity associated with the day of the startAndEndDate.
Remarks

Notes, Appointments, and Holidays are collectively referred to as 'activities'.

For Notess, the time of startAndEndDate is not used. Instead the beginning of the day until the end of the day are checked.

Example
This example uses the DoesDateRangeHaveActivity method to determine whether the current day has any appointments, holidays, or notes.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.IO
Imports System.Globalization

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

        '	Set the 'useTime' parameter to false so that the method checks for activity
        '	that occurs at any time from midnight to 11:59:59PM
        Dim todayHasAnyActivity As Boolean = Me.ultraCalendarInfo1.DoesDateRangeHaveActivity(DateTime.Today.Date.AddHours(9.0F), DateTime.Today.Date.AddHours(9.5F), False)

        '	Set the 'useTime' parameter to true so that the method only checks for activity
        '	that occurs between the hours specified by the start and end time (9 and 9:30AM).
        Dim todayHasWorkingHourActivity As Boolean = Me.ultraCalendarInfo1.DoesDateRangeHaveActivity(DateTime.Today.Date.AddHours(9.0F), DateTime.Today.Date.AddHours(9.5F), True)

        '	Display the activity status for the current day
        Dim info As String = String.Empty
        If (Not todayHasAnyActivity And Not todayHasWorkingHourActivity) Then
            info += "There is no activity for " + DateTime.Today.ToLongDateString() + "." + vbCrLf
        Else
            If (todayHasAnyActivity) Then
                info += "There is activity for " + DateTime.Today.ToLongDateString() + "." + vbCrLf
                If (todayHasWorkingHourActivity) Then
                    info += "There is activity between the hours of 9AM and 9:30AM for " + DateTime.Today.ToLongDateString() + "." + vbCrLf
                End If
            End If
        End If

        MessageBox.Show(info, "DoesDateRangeHaveActivity", MessageBoxButtons.OK)

    End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using System.IO;
using System.Globalization;

		private void button1_Click(object sender, System.EventArgs e)
		{
			
			//	Set the 'useTime' parameter to false so that the method checks for activity
			//	that occurs at any time from midnight to 11:59:59PM
			bool todayHasAnyActivity = this.ultraCalendarInfo1.DoesDateRangeHaveActivity( DateTime.Today.Date.AddHours( 9.0F ), DateTime.Today.Date.AddHours( 9.5F ), false );

			//	Set the 'useTime' parameter to true so that the method only checks for activity
			//	that occurs between the hours specified by the start and end time (9 and 9:30AM).
			bool todayHasWorkingHourActivity = this.ultraCalendarInfo1.DoesDateRangeHaveActivity( DateTime.Today.Date.AddHours( 9.0F ), DateTime.Today.Date.AddHours( 9.5F ), true );

			//	Display the activity status for the current day
			string info = string.Empty;
			if ( ! todayHasAnyActivity && ! todayHasWorkingHourActivity )
				info += "There is no activity for " + DateTime.Today.ToLongDateString() + "." + "\n";
			else
			{
				if ( todayHasAnyActivity )
					info += "There is activity for " + DateTime.Today.ToLongDateString() + "." + "\n";
				if ( todayHasWorkingHourActivity )
					info += "There is activity between the hours of 9AM and 9:30AM for " + DateTime.Today.ToLongDateString() + "." + "\n";
			}

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