property Calendar.Selection as Variant
Returns or sets a safe array of selected dates in the calendar panel.

TypeDescription
Variant A safe array of dates to be selected, or a string expression that indicates the date to be selected. When passing a string the Selection property supports value, operators and predefined functions as listed bellow
The Selection property of the Calendar object can be used to set or get the current selection (dates) in the control's calendar panel. The Selection property of control can be used to set or get the current selection (events) in the control's schedule panel.

The SingleSel property indicates whether the user can select one or multiple dates. As an alternative, you can use the SelCount/SelDate property to retrieve the collection of selected dates in the calendar panel. The AllowSelectDate property indicates the keys combination so the user can select new dates in the calendar panel, and so, new dates to be shown in the schedule view. Once the user starts selecting a new date in the calendar panel, the control fires the LayoutStartChanging(exCalendarSelectionChange). Once a new date is selected, the LayoutEndChanging(exCalendarSelectionChange) event occurs. The DateFromPoint property indicates the date in the calendar panel from the cursor. The /NET and /WPF configurations provides the SelDates property equivalent of Selection, instead the SelDates returns a collection od DateTime objects (public virtual List<DateTime> SelDates). The ClipToSel property indicates whether the control clips the schedule panel to view the selected dates only.

The Selection property gets the selection as:

The Selection property sets the selection based on the SingleSel property as follows:

When using the string format ( as Selection = "month(value) = 5" ), the value keyword indicates the date being queried for selection, and the expression supports the following predefined operators and functions.

The supported binary arithmetic operators are:

The supported unary boolean operators are:

The supported binary boolean operators are:

The supported binary boolean operators, all these with the same priority 0, are :

The supported ternary operators, all these with the same priority 0, are :

"expression ? true_part : false_part"

, while it executes and returns the true_part if the expression is true, else it executes and returns the false_part. For instance, the "%0 = 1 ? 'One' : (%0 = 2 ? 'Two' : 'not found')" returns 'One' if the value is 1, 'Two' if the value is 2, and 'not found' for any other value. A n-ary equivalent operation is the case() statement, which is available in newer versions of the component.

The supported n-ary operators are (with priority 5):

"expression array (c1,c2,c3,...cn)"

, where the c1, c2, ... are constant elements. The constant elements could be numeric, date or string expressions. For instance the "month(value)-1 array ('J','F','M','A','M','Jun','J','A','S','O','N','D')" is equivalent with "month(value)-1 case (default:''; 0:'J';1:'F';2:'M';3:'A';4:'M';5:'Jun';6:'J';7:'A';8:'S';9:'O';10:'N';11:'D')".

"expression in (c1,c2,c3,...cn)"

, where the c1, c2, ... are constant elements. The constant elements could be numeric, date or string expressions. For instance the "value in (11,22,33,44,13)" is equivalent with "(expression = 11) or (expression = 22) or (expression = 33) or (expression = 44) or (expression = 13)". The in operator is not a time consuming as the equivalent or version is, so when you have large number of constant elements it is recommended using the in operator. Shortly, if the collection of elements has 1000 elements the in operator could take up to 8 operations in order to find if an element fits the set, else if the or statement is used, it could take up to 1000 operations to check, so by far, the in operator could save time on finding elements within a collection.

"expression switch (default,c1,c2,c3,...,cn)"

, where the c1, c2, ... are constant elements, and the default is a constant element being returned when the element is not found in the collection. The constant elements could be numeric, date or string expressions. The equivalent syntax is "%0 = c 1 ? c 1 : ( %0 = c 2 ? c 2 : ( ... ? . : default) )". The switch operator is very similar with the in operator excepts that the first element in the switch is always returned by the statement if the element is not found, while the returned value is the value itself instead -1. For instance, the "%0 switch ('not found',1,4,7,9,11)" gets 1, 4, 7, 9 or 11, or 'not found' for any other value. As the in operator the switch operator uses binary searches for fitting the element, so it is quicker that iif (immediate if operator) alterative.

"expression case ([default : default_expression ; ] c1 : expression1 ; c2 : expression2 ; c3 : expression3 ;....)"

If the default part is missing, the case() operator returns the value of the expression if it is not found in the collection of cases ( c1, c2, ...). For instance, if the value of expression is not any of c1, c2, .... the default_expression is executed and returned. If the value of the expression is c1, then the case() operator executes and returns the expression1. The default, c1, c2, c3, ... must be constant elements as numbers, dates or strings. For instance, the "date(shortdate(value)) case (default:0 ; #1/1/2002#:1 ; #2/1/2002#:1; #4/1/2002#:1; #5/1/2002#:1)" indicates that only #1/1/2002#, #2/1/2002#, #4/1/2002# and #5/1/2002# dates returns 1, since the others returns 0. For instance the following sample specifies the hour being non-working for specified dates: "date(shortdate(value)) case(default:0;#4/1/2009# : hour(value) >= 6 and hour(value) <= 12 ; #4/5/2009# : hour(value) >= 7 and hour(value) <= 10 or hour(value) in(15,16,18,22); #5/1/2009# : hour(value) <= 8)" statement indicates the working hours for dates as follows:

The in, switch and case() use binary search to look for elements so they are faster then using iif and or expressions.

Obviously, the priority of the operations inside the expression is determined by ( ) parenthesis and the priority for each operator.

The supported conversion unary operators are:

Other known operators for numbers are:

Other known operators for strings are:

Other known operators for dates are:

The following sample shows how you can enumerate the selected dates, in the calendar panel, once the LayoutEndChanging(exCalendarSelectionChange) event occurs.

VB

Private Sub Schedule1_LayoutEndChanging(ByVal Operation As EXSCHEDULELibCtl.LayoutChangingEnum)
    If Operation = exCalendarSelectionChange Then
        Dim d As Variant
        For Each d In Schedule1.Calendar.Selection
            Debug.Print "Select: " & d
        Next
    End If
End Sub

VB/NET

Private Sub Exschedule1_LayoutEndChanging(ByVal sender As System.Object, ByVal Operation As exontrol.EXSCHEDULELib.LayoutChangingEnum) Handles Exschedule1.LayoutEndChanging
    If Operation = exontrol.EXSCHEDULELib.LayoutChangingEnum.exCalendarSelectionChange Then
        For Each d As DateTime In Exschedule1.Calendar.SelDates
            Debug.Print(d.ToString())
        Next
    End If
End Sub

or:

Private Sub Exschedule1_LayoutEndChanging(ByVal sender As System.Object, ByVal Operation As exontrol.EXSCHEDULELib.LayoutChangingEnum) Handles Exschedule1.LayoutEndChanging
    If Operation = exontrol.EXSCHEDULELib.LayoutChangingEnum.exCalendarSelectionChange Then
        For Each d As DateTime In Exschedule1.Calendar.Selection
            Debug.Print(d.ToString())
        Next
    End If
End Sub

C#

private void exschedule1_LayoutEndChanging(object sender, exontrol.EXSCHEDULELib.LayoutChangingEnum Operation)
{
    if ( Operation == exontrol.EXSCHEDULELib.LayoutChangingEnum.exCalendarSelectionChange  )
    {
        foreach (DateTime d in exschedule1.Calendar.SelDates)
            System.Diagnostics.Debug.Print(d.ToString());
    }
}

or:

private void exschedule1_LayoutEndChanging(object sender, exontrol.EXSCHEDULELib.LayoutChangingEnum Operation)
{
    if ( Operation == exontrol.EXSCHEDULELib.LayoutChangingEnum.exCalendarSelectionChange  )
    {
        foreach (DateTime d in exschedule1.Calendar.Selection as Array)
            System.Diagnostics.Debug.Print(d.ToString());
    }
}

VFP

*** ActiveX Control Event ***
LPARAMETERS operation
*	1 ' exCalendarSelectionChange
    If Operation = 1 Then
    	for i = 0 to thisform.Schedule1.Calendar.SelCount() - 1
    		wait window TToC(thisform.Schedule1.Calendar.SelDate(i))
    	next
    EndIf

C++

void LayoutEndChangingSchedule1(long Operation)
{
	if ( Operation == EXSCHEDULELib::exCalendarSelectionChange )
	{
		_variant_t selection = m_spSchedule->Calendar->Selection;
		if ( V_VT( &selection ) == ( VT_ARRAY | VT_VARIANT ) )
		{
			BYTE* p = NULL;
			long nCount = 0;
			if ( SUCCEEDED( SafeArrayGetUBound( V_ARRAY( &selection ), 1, &nCount ) ) )
			{
				if ( SUCCEEDED( SafeArrayAccessData( V_ARRAY( &selection ), (LPVOID*)&p ) ) )
				{
					for ( long i = 0; i < nCount + 1; i++, p += sizeof(VARIANT) )
					{
						VARIANT* pValue = (VARIANT*)p;
						if ( V_VT( pValue ) == VT_DATE )
						{
							CString strMessage;
							strMessage.Format( _T("Select: %f\r\n"), V_DATE( pValue ) );
							OutputDebugString( strMessage );
						}
					}
					SafeArrayUnaccessData( V_ARRAY( &selection ) );
				}
			}
		}
	}
}

where m_spSchedule is of EXSCHEDULELib::ISchedulePtr type.

The following sample selects the last three days ( today, yesterday, and a day before ):

VBA (MS Access, Excell...)

With Schedule1
	With .Calendar
		.NonworkingDays = 0
		.ShowNonMonthDays = False
		.FirstWeekDay = 0
		.Selection = "(int(date(``)) - value) in (1,2,0)"
	End With
	.BorderSelStyle = -1
	.Background(81) = RGB(240,240,240)
End With

VB6

With Schedule1
	With .Calendar
		.NonworkingDays = 0
		.ShowNonMonthDays = False
		.FirstWeekDay = exSunday
		.Selection = "(int(date(``)) - value) in (1,2,0)"
	End With
	.BorderSelStyle = exNoLines
	.Background(exScheduleMarkTodayBackColor) = RGB(240,240,240)
End With

VB.NET

With Exschedule1
	With .Calendar
		.NonworkingDays = 0
		.ShowNonMonthDays = False
		.FirstWeekDay = exontrol.EXSCHEDULELib.WeekDayEnum.exSunday
		.Selection = "(int(date(``)) - value) in (1,2,0)"
	End With
	.BorderSelStyle = exontrol.EXSCHEDULELib.LinesStyleEnum.exNoLines
	.set_Background(exontrol.EXSCHEDULELib.BackgroundPartEnum.exScheduleMarkTodayBackColor,Color.FromArgb(0,0,0))
End With

VB.NET for /COM

With AxSchedule1
	With .Calendar
		.NonworkingDays = 0
		.ShowNonMonthDays = False
		.FirstWeekDay = EXSCHEDULELib.WeekDayEnum.exSunday
		.Selection = "(int(date(``)) - value) in (1,2,0)"
	End With
	.BorderSelStyle = EXSCHEDULELib.LinesStyleEnum.exNoLines
	.set_Background(EXSCHEDULELib.BackgroundPartEnum.exScheduleMarkTodayBackColor,15790320)
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'EXSCHEDULELib' for the library: 'ExSchedule 1.0 Control Library'

	#import <ExSchedule.dll>
	using namespace EXSCHEDULELib;
*/
EXSCHEDULELib::ISchedulePtr spSchedule1 = GetDlgItem(IDC_SCHEDULE1)->GetControlUnknown();
EXSCHEDULELib::ICalendarPtr var_Calendar = spSchedule1->GetCalendar();
	var_Calendar->PutNonworkingDays(0);
	var_Calendar->PutShowNonMonthDays(VARIANT_FALSE);
	var_Calendar->PutFirstWeekDay(EXSCHEDULELib::exSunday);
	var_Calendar->PutSelection("(int(date(``)) - value) in (1,2,0)");
spSchedule1->PutBorderSelStyle(EXSCHEDULELib::exNoLines);
spSchedule1->PutBackground(EXSCHEDULELib::exScheduleMarkTodayBackColor,RGB(240,240,240));

C++ Builder

Exschedulelib_tlb::ICalendarPtr var_Calendar = Schedule1->Calendar;
	var_Calendar->NonworkingDays = 0;
	var_Calendar->ShowNonMonthDays = false;
	var_Calendar->FirstWeekDay = Exschedulelib_tlb::WeekDayEnum::exSunday;
	var_Calendar->set_Selection(TVariant("(int(date(``)) - value) in (1,2,0)"));
Schedule1->BorderSelStyle = Exschedulelib_tlb::LinesStyleEnum::exNoLines;
Schedule1->Background[Exschedulelib_tlb::BackgroundPartEnum::exScheduleMarkTodayBackColor] = RGB(240,240,240);

C#

exontrol.EXSCHEDULELib.Calendar var_Calendar = exschedule1.Calendar;
	var_Calendar.NonworkingDays = 0;
	var_Calendar.ShowNonMonthDays = false;
	var_Calendar.FirstWeekDay = exontrol.EXSCHEDULELib.WeekDayEnum.exSunday;
	var_Calendar.Selection = "(int(date(``)) - value) in (1,2,0)";
exschedule1.BorderSelStyle = exontrol.EXSCHEDULELib.LinesStyleEnum.exNoLines;
exschedule1.set_Background(exontrol.EXSCHEDULELib.BackgroundPartEnum.exScheduleMarkTodayBackColor,Color.FromArgb(0,0,0));

JavaScript

<OBJECT classid="clsid:9B09E13D-7A88-4299-9DBE-383380435377" id="Schedule1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
	var var_Calendar = Schedule1.Calendar;
		var_Calendar.NonworkingDays = 0;
		var_Calendar.ShowNonMonthDays = false;
		var_Calendar.FirstWeekDay = 0;
		var_Calendar.Selection = "(int(date(``)) - value) in (1,2,0)";
	Schedule1.BorderSelStyle = -1;
	Schedule1.Background(81) = 15790320;
</SCRIPT>

C# for /COM

EXSCHEDULELib.Calendar var_Calendar = axSchedule1.Calendar;
	var_Calendar.NonworkingDays = 0;
	var_Calendar.ShowNonMonthDays = false;
	var_Calendar.FirstWeekDay = EXSCHEDULELib.WeekDayEnum.exSunday;
	var_Calendar.Selection = "(int(date(``)) - value) in (1,2,0)";
axSchedule1.BorderSelStyle = EXSCHEDULELib.LinesStyleEnum.exNoLines;
axSchedule1.set_Background(EXSCHEDULELib.BackgroundPartEnum.exScheduleMarkTodayBackColor,(uint)ColorTranslator.ToWin32(Color.FromArgb(240,240,240)));

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_Calendar;
	anytype var_Calendar;
	;

	super();

	var_Calendar = exschedule1.Calendar(); com_Calendar = var_Calendar;
		com_Calendar.NonworkingDays(0);
		com_Calendar.ShowNonMonthDays(false);
		com_Calendar.FirstWeekDay(0/*exSunday*/);
		com_Calendar.Selection("(int(date(``)) - value) in (1,2,0)");
	exschedule1.BorderSelStyle(-1/*exNoLines*/);
	exschedule1.Background(81/*exScheduleMarkTodayBackColor*/,WinApi::RGB2int(240,240,240));
}

Delphi 8 (.NET only)

with AxSchedule1 do
begin
	with Calendar do
	begin
		NonworkingDays := 0;
		ShowNonMonthDays := False;
		FirstWeekDay := EXSCHEDULELib.WeekDayEnum.exSunday;
		Selection := '(int(date(``)) - value) in (1,2,0)';
	end;
	BorderSelStyle := EXSCHEDULELib.LinesStyleEnum.exNoLines;
	set_Background(EXSCHEDULELib.BackgroundPartEnum.exScheduleMarkTodayBackColor,$f0f0f0);
end

Delphi (standard)

with Schedule1 do
begin
	with Calendar do
	begin
		NonworkingDays := 0;
		ShowNonMonthDays := False;
		FirstWeekDay := EXSCHEDULELib_TLB.exSunday;
		Selection := '(int(date(``)) - value) in (1,2,0)';
	end;
	BorderSelStyle := EXSCHEDULELib_TLB.exNoLines;
	Background[EXSCHEDULELib_TLB.exScheduleMarkTodayBackColor] := $f0f0f0;
end

VFP

with thisform.Schedule1
	with .Calendar
		.NonworkingDays = 0
		.ShowNonMonthDays = .F.
		.FirstWeekDay = 0
		.Selection = "(int(date(``)) - value) in (1,2,0)"
	endwith
	.BorderSelStyle = -1
	.Object.Background(81) = RGB(240,240,240)
endwith

dBASE Plus

local oSchedule,var_Calendar

oSchedule = form.Activex1.nativeObject
var_Calendar = oSchedule.Calendar
	var_Calendar.NonworkingDays = 0
	var_Calendar.ShowNonMonthDays = false
	var_Calendar.FirstWeekDay = 0
	var_Calendar.Selection = "(int(date(``)) - value) in (1,2,0)"
oSchedule.BorderSelStyle = -1
oSchedule.Template = [Background(81) = 0xf0f0f0] // oSchedule.Background(81) = 0xf0f0f0

XBasic (Alpha Five)

Dim oSchedule as P
Dim var_Calendar as P

oSchedule = topparent:CONTROL_ACTIVEX1.activex
var_Calendar = oSchedule.Calendar
	var_Calendar.NonworkingDays = 0
	var_Calendar.ShowNonMonthDays = .f.
	var_Calendar.FirstWeekDay = 0
	var_Calendar.Selection = "(int(date(``)) - value) in (1,2,0)"
oSchedule.BorderSelStyle = -1
oSchedule.Template = "Background(81) = 15790320" ' oSchedule.Background(81) = 15790320

Visual Objects

local var_Calendar as ICalendar

var_Calendar := oDCOCX_Exontrol1:Calendar
	var_Calendar:NonworkingDays := 0
	var_Calendar:ShowNonMonthDays := false
	var_Calendar:FirstWeekDay := exSunday
	var_Calendar:Selection := "(int(date(``)) - value) in (1,2,0)"
oDCOCX_Exontrol1:BorderSelStyle := exNoLines
oDCOCX_Exontrol1:[Background,exScheduleMarkTodayBackColor] := RGB(240,240,240)

PowerBuilder

OleObject oSchedule,var_Calendar

oSchedule = ole_1.Object
var_Calendar = oSchedule.Calendar
	var_Calendar.NonworkingDays = 0
	var_Calendar.ShowNonMonthDays = false
	var_Calendar.FirstWeekDay = 0
	var_Calendar.Selection = "(int(date(``)) - value) in (1,2,0)"
oSchedule.BorderSelStyle = -1
oSchedule.Background(81,RGB(240,240,240))