Skip to content

Latest commit

 

History

History
37 lines (31 loc) · 3.14 KB

File metadata and controls

37 lines (31 loc) · 3.14 KB

WinForms Scheduler - Enforce task dependencies in the Gantt view

This example handles the AllowAppointmentConflicts event to implement restrictions on appointment editing (appointments linked with a dependency should follow dependency rules).

If two appointments are linked with a Finish-to-Start dependency, the Finish value of the parent appointment should always be less than or equal to the Start value of the dependent appointment. The example uses GetDependenciesByDependentId and GetDependenciesByParentId methods to obtain dependency collections.

private void schedulerControl1_AllowAppointmentConflicts(object sender, AppointmentConflictEventArgs e) {
    e.Conflicts.Clear();
    AppointmentDependencyBaseCollection depCollectionDep = 
        schedulerDataStorage1.AppointmentDependencies.Items.GetDependenciesByDependentId(e.Appointment.Id);
    if (depCollectionDep.Count > 0) {
        if (CheckForInvalidDependenciesAsDependent(depCollectionDep, e.AppointmentClone))
            e.Conflicts.Add(e.AppointmentClone);
    }
    AppointmentDependencyBaseCollection depCollectionPar = 
        schedulerDataStorage1.AppointmentDependencies.Items.GetDependenciesByParentId(e.Appointment.Id);
    if (depCollectionPar.Count > 0) {
        if (CheckForInvalidDependenciesAsParent(depCollectionPar, e.AppointmentClone))
            e.Conflicts.Add(e.AppointmentClone);
    }
}

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)