Remove

CalendarCollection.Remove method

Removes Calendar from Project CalendarCollection.

public bool Remove(Calendar item)
ParameterTypeDescription
itemCalendarThe calendar to remove.

Return Value

If removed returns true, else returns false.

Exceptions

exceptioncondition
InvalidOperationExceptionThrown when calendar cannot be removed.

Examples

Shows how to replace a calendar in the collection.

var project = new Project(DataDir + "Project5.mpp");

var calendar = project.Calendars.GetByName("TestCalendar");
if (calendar != null)
{
    project.Calendars.Remove(calendar);
}

// add new calendar
project.Calendars.Add("New Calendar");
project.Save(OutDir + "ReplaceCalendarWithNewCalendar_out.mpp", SaveFileFormat.Mpp);

See Also