GanttView for WPF | ComponentOne
Task Elements / Constraints
In This Topic
    Constraints
    In This Topic

    Constraints define the degree or extent to which a task can be rescheduled in a project schedule. This feature helps in scheduling automatic tasks on the basis of various factors such as start and finish date, type of constraint, task priority and duration. Constraints cannot be applied to manual tasks. This is because GanttView does not schedule manual tasks, so applying constraints on them has no effect.

    You can add constraints in GanttView to schedule automatic tasks by setting ConstraintDate and ConstraintType properties of the Task class. The ConstraintDate property specifies the start or finish date for the applied constraint, while ConstraintType property specifies the type of constraint (specified in the following table) using the ConstraintType enumeration.

    Enumeration Value Description
    Default Allows scheduling the task as soon as possible if the project is scheduled from the start date; Or schedules the task as late as possible if the project is scheduled from the finish date.
    FinishNoEarlierThan Allows scheduling tasks in a way that they must finish on or after the defined constraint date.
    FinishNoLaterThan Allows scheduling tasks in a way that they must finish on or before the defined constraint date.
    MustFinishOn Allows scheduling tasks such that they must finish on the defined constraint date.
    MustStartOn Allows scheduling tasks such that they must start on the defined constraint date.
    StartNoEarlierThan Allows scheduling tasks such that they must start on or after the constraint date.
    StartNoLaterThan Allows scheduling tasks such that they must start on or before the constraint date.

    Apply constraints

    To apply constraints, you need to set the ConstraintDate and ConstraintType properties as demonstrated in the following code. The following example uses the sample created in Quick Start.

    C#
    Copy Code
    //Applying constraints
    t.ConstraintDate = new DateTime(2022, 5, 5);
    t.ConstraintType = ConstraintType.MustFinishOn;