property Events.Item (Handle as Variant) as Event
Returns a specific Event of the Events collection, giving its handle.

TypeDescription
Handle as Variant
  • A long expression that indicates the handle of the event. The Handle identifies unique the event, and is is allocated by the control. The Handle property of the event specifies the event's handle. 
  • A double/float expression that specifies the event's identifier. The KnownProperty(exEventID) property specifies the event's identifier. The Handle is automatically generated by the control, and can not be changed, while the IDentifier can be set by the user.
Event An Event object associated with the giving Handle.

The Item property access an individual element of the collection. 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. You can use the Remove method to remove a specific event, so the Count property is decreased.

The following VB sample accesses/prints the Event's user data giving its handle:

With Schedule1.Events
    Debug.Print .Item(h).UserData
End With

The following VB sample accesses/prints the Event's user data giving its identifier:

With Schedule1.Events
    Debug.Print .Item(CDbl(i)).UserData
End With

where the h and i variables are of long type as in the following statement:

Dim h As Long
Dim i As Long

Private Sub Form_Load()
    i = 100
    With Schedule1.Events.Add(#4/5/2014 10:00:00 AM#, #4/5/2014 2:00:00 PM#)
        .KnownProperty(exEventID) = i
        .UserData = "this is a bit of text associated with the event"
        h = .Handle
    End With
End Sub

Shortly, the h member is generated by the control in the Handle property ( read-only ), while i member can be set by the user.

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:

For Each e as Object In thisform.Schedule1.Events
	LOCAL ee as Object
	ee = thisform.Schedule1.Events(e)
	WAIT WINDOW"Event " + TTOC(ee.Start) + " "  + TTOC(ee.End)
ENDFOR

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.