Editing and exiting CalDav event

Hoping someone might be able to help me I am using the AdvCalDav component and have been able to successfully access the calendar and add events.  Now I need to be able to edit these items.

In the help file I find this :-

to update an item, use:
cdi := AdvCalDav1.Items[IndexOfItemToUpdate]; // change the contact data via: // cdi.vCalendar.vEvents[0].Summary := NewSummary; cdi.Update;

However there is no mention of how they obtain the value IndexOfItemToUpdate
Is there some function I that you can call to lookup the event by ID or by UID or some other field?

If some one has an example of how to find an existing event in the CalDav Calendar could they please share.

This is the index of the item in the list of events that were first retrieved, i.e. the  list filled in AdvCalDav.Items after setting AdvCalDav.Active to true.




I already know that the IndexOfItemToUpdate is an integer between 0 and number of CalDav records minus 1.  But given a UID or other unique identifier how do I find the index number of the matching record?  This is what I am using currently and it seems to work although slow.

[Snip]

    AdvCalDav.Open;

   // If Modifying an existing records then Filter the calendar by 48 hours to
   // make the sequential search smaller - Code left out for brevity

    iCalId := -1;   // Not found - new event
    if sUID > '' then   // sUID is my UID as previously stored in the Calendar and in a database.
    begin
      for iItem := 0 to AdvCalDav.Items.Count - 1 do
      begin
        try
          if AdvCalDav.Items[iItem].vCalendar.vEvents[0].UID = sUid then
          begin
            iCalId := iItem;
            BREAK; // WE found the event
          end;

        except
          // Do nothing
        end;
      end;
    end;

    // Add or edit the card
    if iCalId = -1 then
    begin
      cdi := AdvCalDav.Items.Insert(sCalendarName);
      cdi.vCalendar.vEvents.Add;
    end
    else
       cdi := AdvCalDav.Items[iCalId];

[snip]  

A search function would be better i.e.
AdvCalDav.Items.FindbyUid(sUID);   // Return Index number if found or -1 if not found

Additionally when AdvCalDav opens and parse the file it could put the UID values in a BTree to enhance the search.

Cheers Trevor

At this moment, there is not yet such Find() function. We'll consider this for a future update.