EventCollection
Namespace: Wisej.Web.Ext.FullCalendar
Assembly: Wisej.Web.Ext.FullCalendar (4.1.0.0)
Collection of Event objects.
- C#
- VB.NET
public class EventCollection : IList<Event>, ICollection<Event>, IEnumerable<Event>, IEnumerable
Public Class EventCollection
Inherits IList(Of [Event])
Implements ICollection(Of [Event]), IEnumerable(Of [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
Count
Int32: Returns the number of Event objects in the collection.
In virtual mode returns VirtualSize.
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:
- ArgumentOutOfRangeException index is less than 0 or not less than Count.
- InvalidOperationException The calendar is in virtual mode and either the event is being set, or the RetrieveVirtualEvent handler didn't return an event.
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;
}
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:
- ArgumentNullException id is null when setting the event.
- InvalidOperationException The calendar is in virtual mode and either the event is being set, or the RetrieveVirtualEvent handler didn't return an event.
Example:
Finding an event by its ID:
var ev = this.fullCalendar1.Events["m42"];
if (ev != null)
ev.Title = "Budget meeting (moved)";
Methods
Add(day)
Adds a new all-day Event to the collection.
Returns: Event. The newly added all-day Event.
Throws:
- InvalidOperationException The calendar is in virtual mode.
Example:
Adding an all-day event:
this.fullCalendar1.Events.Add(new DateTime(2026, 12, 25)).Title = "Christmas";
Add(start, end)
Adds a new Event to the collection.
| Parameter | Type | Description |
|---|---|---|
| start | DateTime | The starting DateTime date and time of the event. |
| end | DateTime | The ending DateTime date and time of the event. |
Returns: Event. The newly added Event.
Throws:
- InvalidOperationException The calendar is in virtual mode.
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";
Add(start, duration)
Adds a new Event to the collection.
| Parameter | Type | Description |
|---|---|---|
| start | DateTime | The starting DateTime date and time of the event. |
| duration | TimeSpan | The TimeSpan duration of the event. |
Returns: Event. The newly added Event.
Throws:
- InvalidOperationException The calendar is in virtual mode.
Example:
Adding a 45 minutes event:
this.fullCalendar1.Events.Add(new DateTime(2026, 10, 6, 14, 0, 0), TimeSpan.FromMinutes(45)).Title = "Interview";
Add(id, day)
Adds a new all-day Event to the collection.
| Parameter | Type | Description |
|---|---|---|
| id | String | A string that represents the ID of this event. |
| day | DateTime | The 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:
- ArgumentNullException id is null or empty.
- InvalidOperationException The calendar is in virtual mode.
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";
Add(id, start, end)
Adds a new Event to the collection.
| Parameter | Type | Description |
|---|---|---|
| id | String | A string that represents the ID of this event. |
| start | DateTime | The starting DateTime date and time of the event. |
| end | DateTime | The 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:
- ArgumentNullException id is null or empty.
- InvalidOperationException The calendar is in virtual mode.
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;
Add(id, start, duration)
Adds a new Event to the collection.
| Parameter | Type | Description |
|---|---|---|
| id | String | A string that represents the ID of this event. |
| start | DateTime | The starting DateTime date and time of the event. |
| duration | TimeSpan | The 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:
- ArgumentNullException id is null or empty.
- InvalidOperationException The calendar is in virtual mode.
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";
Add(ev)
Adds a new Event 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:
- ArgumentNullException ev is null.
- InvalidOperationException The calendar is in virtual mode.
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
});
AddRange(list)
Adds the list of Event items to the collection.
| Parameter | Type | Description |
|---|---|---|
| list | ICollection<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:
- ArgumentNullException list is null.
- InvalidOperationException The calendar is in virtual mode.
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);
Clear()
Removes all events.
Does nothing when the calendar is in virtual mode.
Example:
Removing all the events:
this.fullCalendar1.Events.Clear();
Contains(ev)
Checks if the specified Event exists in the collection.
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);
CopyTo(array, arrayIndex)
Copies all events to the specified array.
| Parameter | Type | Description |
|---|---|---|
| array | Event[] | The destination array. |
| arrayIndex | Int32 | The 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);
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;
}
IndexOf(ev)
Returns the index of the specified Event in the collection.
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);
Insert(index, ev)
Inserts the Event in the collection at the specified position.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The position in the collection where to insert the event. |
| ev | Event | The 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:
- ArgumentNullException ev is null.
- InvalidOperationException The calendar is in virtual mode.
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" });
OnCollectionChanged(e)
Fires the CollectionChanged event.
| Parameter | Type | Description |
|---|---|---|
| e | CollectionChangeEventArgs | A CollectionChangeEventArgs that contains the event data. |
Remove(ev)
Removes the Event from the collection and updates the calendar.
Returns: Boolean. Always true, also when ev was not in the collection.
Throws:
- ArgumentNullException ev is null.
- InvalidOperationException The calendar is in virtual mode.
Example:
Removing the event that was double clicked:
private void fullCalendar1_EventDoubleClick(object sender, EventClickEventArgs e)
{
this.fullCalendar1.Events.Remove(e.Event);
}
RemoveAt(index)
Removes the Event at the specified index from the collection and updates the calendar.
Throws:
- ArgumentOutOfRangeException index is less than 0 or not less than Count.
- InvalidOperationException The calendar is in virtual mode.
Example:
Removing the last event:
var events = this.fullCalendar1.Events;
if (events.Count > 0)
events.RemoveAt(events.Count - 1);
Events
CollectionChanged
CollectionChangeEventHandler Fired when the collection changes.