Skip to main content

EventCollection

Namespace: Wisej.Web.Ext.FullCalendar

Assembly: Wisej.Web.Ext.FullCalendar (4.1.0.0)

Collection of Event objects.

public class EventCollection : IList<Event>, ICollection<Event>, IEnumerable<Event>, IEnumerable

The collection is returned by Events. Any change reloads the events on the client after the current request. Event IDs are unique in the collection: adding or inserting an event with the ID of an existing event replaces it, and events without an ID receive an automatic ID. When VirtualMode is true, the collection can't be modified and the indexers retrieve the events by firing RetrieveVirtualEvent.

Properties​

Instance member Count​

Int32: Returns the number of Event objects in the collection.

In virtual mode returns VirtualSize.

Instance member Item(index)​

Event: Returns or sets the Event at the specified position.

Value: The Event at the specified position.

In virtual mode, reading an event fires RetrieveVirtualEvent with EventIndex set to index .

Throws:

Example:

Iterating the events by index:

for (int i = 0; i < this.fullCalendar1.Events.Count; i++)
{
var ev = this.fullCalendar1.Events[i];
ev.Editable = ev.Start > DateTime.Now;
}

Instance member Item(id)​

Event: Returns or sets the Event identified by the ID.

Value: The Event with the specified ID, or null if not found.

Setting an event replaces the event with the same ID or, when not found, adds the event to the collection. In virtual mode, reading an event fires RetrieveVirtualEvent with EventID set to id .

Throws:

Example:

Finding an event by its ID:

var ev = this.fullCalendar1.Events["m42"];
if (ev != null)
ev.Title = "Budget meeting (moved)";

Methods​

Instance member Add(day)​

Adds a new all-day Event to the collection.

ParameterTypeDescription
dayDateTimeThe DateTime date of the all-day event.

Returns: Event. The newly added all-day Event.

Throws:

Example:

Adding an all-day event:

this.fullCalendar1.Events.Add(new DateTime(2026, 12, 25)).Title = "Christmas";

Instance member Add(start, end)​

Adds a new Event to the collection.

ParameterTypeDescription
startDateTimeThe starting DateTime date and time of the event.
endDateTimeThe ending DateTime date and time of the event.

Returns: Event. The newly added Event.

Throws:

Example:

Adding a timed event:

var ev = this.fullCalendar1.Events.Add(new DateTime(2026, 10, 6, 9, 30, 0), new DateTime(2026, 10, 6, 11, 0, 0));
ev.Title = "Workshop";

Instance member Add(start, duration)​

Adds a new Event to the collection.

ParameterTypeDescription
startDateTimeThe starting DateTime date and time of the event.
durationTimeSpanThe TimeSpan duration of the event.

Returns: Event. The newly added Event.

Throws:

Example:

Adding a 45 minutes event:

this.fullCalendar1.Events.Add(new DateTime(2026, 10, 6, 14, 0, 0), TimeSpan.FromMinutes(45)).Title = "Interview";

Instance member Add(id, day)​

Adds a new all-day Event to the collection.

ParameterTypeDescription
idStringA string that represents the ID of this event.
dayDateTimeThe DateTime date of the all-day event.

Returns: Event. The newly added Event.

If the collection already contains an event with the same id , it is replaced.

Throws:

Example:

Adding an all-day event with a known ID:

this.fullCalendar1.Events.Add("holiday-2026-12-25", new DateTime(2026, 12, 25)).Title = "Christmas";

Instance member Add(id, start, end)​

Adds a new Event to the collection.

ParameterTypeDescription
idStringA string that represents the ID of this event.
startDateTimeThe starting DateTime date and time of the event.
endDateTimeThe ending DateTime date and time of the event.

Returns: Event. The newly added Event.

If the collection already contains an event with the same id , it is replaced.

Throws:

Example:

Adding an event using the primary key of a record as the ID:

var ev = this.fullCalendar1.Events.Add(appointment.Id.ToString(), appointment.Start, appointment.End);
ev.Title = appointment.Subject;

Instance member Add(id, start, duration)​

Adds a new Event to the collection.

ParameterTypeDescription
idStringA string that represents the ID of this event.
startDateTimeThe starting DateTime date and time of the event.
durationTimeSpanThe TimeSpan duration of the event.

Returns: Event. The newly added Event.

If the collection already contains an event with the same id , it is replaced.

Throws:

Example:

Adding a two hours event with an ID:

this.fullCalendar1.Events.Add("training", new DateTime(2026, 10, 8, 13, 0, 0), TimeSpan.FromHours(2)).Title = "Training";

Instance member Add(ev)​

Adds a new Event to the collection.

ParameterTypeDescription
evEventThe Event to add to the collection.

If the collection already contains an event with the same ID, it is replaced. If the event has no ID, an automatic ID is assigned. If the event belongs to another calendar, it's removed from it.

Throws:

Example:

Adding an event configured in advance:

this.fullCalendar1.Events.Add(new Event(new DateTime(2026, 10, 6, 9, 0, 0), TimeSpan.FromHours(1))
{
Title = "Sprint planning",
BackgroundColor = Color.MediumPurple
});

Instance member AddRange(list)​

Adds the list of Event items to the collection.

ParameterTypeDescription
listICollection<Event>The list of events to add to the collection.

Events with the same ID of an event already in the collection replace the existing events. The events on the client are reloaded only once.

Throws:

Example:

Loading a set of events at once:

var events = appointments
.Select(a => new Event(a.Id.ToString(), a.Start, a.End) { Title = a.Subject })
.ToList();

this.fullCalendar1.Events.Clear();
this.fullCalendar1.Events.AddRange(events);

Instance member Clear()​

Removes all events.

Does nothing when the calendar is in virtual mode.

Example:

Removing all the events:

this.fullCalendar1.Events.Clear();

Instance member Contains(ev)​

Checks if the specified Event exists in the collection.

ParameterTypeDescription
evEventThe Event to look for.

Returns: Boolean. true if ev is in the collection; otherwise, false.

The search compares the event instances, not the IDs. In virtual mode it always returns false.

Example:

Adding an event only if it's not already in the calendar:

if (!this.fullCalendar1.Events.Contains(ev))
this.fullCalendar1.Events.Add(ev);

Instance member CopyTo(array, arrayIndex)​

Copies all events to the specified array.

ParameterTypeDescription
arrayEvent[]The destination array.
arrayIndexInt32The index at which to begin the copy.

In virtual mode there are no events to copy.

Example:

Copying the events to an array:

var array = new Event[this.fullCalendar1.Events.Count];
this.fullCalendar1.Events.CopyTo(array, 0);

Instance member GetEnumerator()​

Returns an enumerator that iterates all the Event objects in the collection.

Returns: IEnumerator<Event>. An enumerator for the Event objects in the collection.

In virtual mode the enumerator doesn't return any event.

Example:

Iterating the events using foreach:

foreach (var ev in this.fullCalendar1.Events)
{
if (ev.Start.Date == DateTime.Today)
ev.BackgroundColor = Color.Red;
}

Instance member IndexOf(ev)​

Returns the index of the specified Event in the collection.

ParameterTypeDescription
evEventThe Event to look for.

Returns: Int32. The index of ev in the collection, or -1 if not found.

Example:

Removing an event using its index:

int index = this.fullCalendar1.Events.IndexOf(ev);
if (index > -1)
this.fullCalendar1.Events.RemoveAt(index);

Instance member Insert(index, ev)​

Inserts the Event in the collection at the specified position.

ParameterTypeDescription
indexInt32The position in the collection where to insert the event.
evEventThe Event to insert.

If the collection already contains an event with the same ID, the existing event is replaced in its current position and index is ignored. The position in the collection doesn't affect how the events are displayed.

Throws:

Example:

Inserting an event at the beginning of the collection:

this.fullCalendar1.Events.Insert(0, new Event(new DateTime(2026, 10, 1)) { Title = "Quarter start" });

Protected member OnCollectionChanged(e)​

Fires the CollectionChanged event.

ParameterTypeDescription
eCollectionChangeEventArgsA CollectionChangeEventArgs that contains the event data.

Instance member Remove(ev)​

Removes the Event from the collection and updates the calendar.

ParameterTypeDescription
evEventThe Event to remove.

Returns: Boolean. Always true, also when ev was not in the collection.

Throws:

Example:

Removing the event that was double clicked:

private void fullCalendar1_EventDoubleClick(object sender, EventClickEventArgs e)
{
this.fullCalendar1.Events.Remove(e.Event);
}

Instance member RemoveAt(index)​

Removes the Event at the specified index from the collection and updates the calendar.

ParameterTypeDescription
indexInt32The index of the Event to remove.

Throws:

Example:

Removing the last event:

var events = this.fullCalendar1.Events;
if (events.Count > 0)
events.RemoveAt(events.Count - 1);

Events​

Instance member CollectionChanged​

CollectionChangeEventHandler Fired when the collection changes.