Version

GetClosestSelectableDate Method

Returns the closest enabled date to the startDate specified.
Syntax
'Declaration
 
Public Function GetClosestSelectableDate( _
   ByVal startDate As Date, _
   ByVal direction As ClosestDayToReturn, _
   ByRef closestDate As Date _
) As Boolean
public bool GetClosestSelectableDate( 
   DateTime startDate,
   ClosestDayToReturn direction,
   ref DateTime closestDate
)

Parameters

startDate
DateTime to start the search.
direction
Bit flags specifying the direction of the search.
closestDate
A by reference DateTime which will be set to the closest enabled date if one is found.

Return Value

A boolean indicating whether an enabled date was found in the direction specified. If true, then the closestDate parameter will be set to that date.
Remarks

In order for a Day to be selectable, the date must be enabled and must be within the MinDate and MaxDate. A date is enabled, if the date specific objects (e.g. Day, Week, Month, etc.) are enabled and the general objects are enabled (e.g. DayOfWeek, MonthOfYear, etc.).

Example
This example uses the GetClosestSelectableDate method to get the first selectable date (i.e., visible and enabled) that falls on or after the current date.

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

        '	Get the the first selectable date (i.e., visible and enabled) that
        '	falls on or after the current date
        Dim selectableDate As DateTime = DateTime.Today
        Me.ultraCalendarInfo1.GetClosestSelectableDate(DateTime.Today, ClosestDayToReturn.OnOrAfter, selectableDate)

        '	Display the first selectable date to the end user
        MessageBox.Show("The first selectable day that falls on or after the current date is " + selectableDate.ToLongDateString() + "." + vbCrLf, "GetClosestSelectableDate", 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)
		{
			
			//	Get the the first selectable date (i.e., visible and enabled) that
			//	falls on or after the current date
			DateTime selectableDate = DateTime.Today;
			this.ultraCalendarInfo1.GetClosestSelectableDate( DateTime.Today, ClosestDayToReturn.OnOrAfter, ref selectableDate );

			//	Display the first selectable date to the end user
			MessageBox.Show( "The first selectable day that falls on or after the current date is " + selectableDate.ToLongDateString() + "." + "\n", "GetClosestSelectableDate", 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