property Events.Count as Long
Returns the number of objects in a collection.

TypeDescription
Long A long expression that specifies the number of events in the schedule.
The Count property gets the number of Event objects in the Events collection. The Add method of the Events collection adds a new event/appointment to the eXSchedule control, so the Count property is increased. The Clear method clears all events in the collection, and so the Count property is set on 0. The Item property access an individual element of the collection. You can use the Remove method to remove a specific event, so the Count property is decreased.

In order to enumerate the events we recommend using the for each statement, instead for i - 0 to Count - 1 as in the following samples.

The following VB sample shows how you can enumerate all events in the control:

Dim e As EXSCHEDULELibCtl.Event
For Each e In Schedule1.Events
    Debug.Print "Event: " & e.Start & " to " & e.End
Next

The following VB/NET sample shows how you can enumerate all events in the control:

For Each ev As exontrol.EXSCHEDULELib.Event In Exschedule1.Events
    Debug.Print("Event: " & ev.Start.ToString() & " " & ev.End.ToString())
Next

The following C# sample shows how you can enumerate all events in the control:

foreach (exontrol.EXSCHEDULELib.Event ev in exschedule1.Events)
    System.Diagnostics.Debug.Print("Event: " + ev.Start.ToString() + " " + ev.End.ToString());

The following VFP sample shows how you can enumerate all events in the control:

*** ActiveX Control Event ***
LPARAMETERS operation
*	1 ' exCalendarSelectionChange
    If Operation = 1 Then
		local d
		For Each d In thisform.Schedule1.Calendar.Selection
			WAIT WINDOW "Select: " + TTOC(d)
		ENDFOR
    EndIf

The following C++ sample shows how you can enumerate all events in the control:

IEnumVARIANTPtr spEnum = m_spSchedule->Events->_NewEnum;
if ( spEnum != NULL )
{
	spEnum->Reset();
	unsigned long n = 0;
	_variant_t vtElement;
	while( SUCCEEDED( spEnum->Next( 1, &vtElement, &n ) ) && ( n != 0 ) )
	{
		EXSCHEDULELib::IEventPtr spEvent = V_DISPATCH( &vtElement );
		if ( spEvent != NULL )
		{
			CString sMessage;
			sMessage.Format(_T("Event: %f %f\r\n"), spEvent->Start, spEvent->End );
			OutputDebugString( sMessage );
		}
	}
}

where m_spSchedule is of EXSCHEDULELib::ISchedulePtr type.