ComponentOne GanttView for WPF
Task Dependency
Features > Task Management > Task Dependency

Tasks created in a project plan are often linked together to create a feasible scheduling relationship. This is called task dependency or dependency. For example, a software development project encompasses various tasks including requirement gathering, product analysis, design, development, quality assurance, release, etc. aligned in phases. In this scenario, every task is fairly dependent on the completion of the other. For instance, quality assurance is dependent on product development, while product development is dependent on requirement and product analysis. Tasks related to quality assurance can only be started once the product development is over. This creates a "finish-to-start" dependency, where product development becomes a predecessor task since it precedes the tasks that depend on it, while quality assurance becomes the successor task as it follows or succeeds the task(s) on which it depends.

Based on all possible relationships, any two tasks can have the following dependencies:

Dependency Description
Finish-to-start The finish date of the predecessor task determines the start date of the successor task.
Finish-to-finish The finish date of the predecessor task determines the finish date of the successor task.
Start-to-finish The start date of the predecessor task determines the finish date of the successor task.
Start-to-start The start date of the predecessor task determines the start date of the successor task.

GanttView supports task dependencies both at runtime as well as in code. The Predecessors tab available in the Task information dialog can be used to create task dependencies at runtime. In addition, dependent tasks can be linked through mouse at runtime. Creating and handling task dependencies in code is explained later in the topic.

In GanttView, task dependencies can be visualized through lines connecting the dependent tasks. The grid area of the GanttView also displays predecessor tasks and dependencies in the Predecessors Column, provided its visibility is enabled. The Predecessors column displays the serial number of the predecessor task along with dependency type in abbreviated form (like SS, SF, or FF), except in case for default dependency, that is Finish-to-start.

The following image shows tasks dependencies created in a GanttView.

Creating task dependencies in code

To create and handle task dependencies, the GanttView control provides the Predecessor class, which can be used to specify the dependence of one or more tasks on the other. The class provides PredecessorTask and PredecessorType properties to set task precedence and dependency between tasks. A delay in days can also be set between the dependent tasks by using the Lag property. The PredecessorType property accepts the following values from the PredecessorType enumeration to indicate the type of dependence:

The following code example illustrates creating a predecessor task, and setting its dependence on another task and its type. This example uses the sample created in the Quick start.

Dim task1 As Task = gv.Tasks.Search("Development")
Dim task2 As Task = gv.Tasks.Search("Quality Assurance")

If task1 IsNot Nothing AndAlso task2 IsNot Nothing AndAlso task2.Predecessors.Count = 0 Then
    'switch to auto-scheduling mode
    task2.Mode = TaskMode.Automatic

    Dim p As New Predecessor()
    p.PredecessorTask = task1
    p.PredecessorType = PredecessorType.FinishToStart
    task2.Predecessors.Add(p)

    'restore the manual mode
    task2.Mode = TaskMode.Manual
End If
Task task1 = gv.Tasks.Search("Development");
Task task2 = gv.Tasks.Search("Quality Assurance");

if (task1 != null && task2 != null && task2.Predecessors.Count == 0)
{
    //switch to auto-scheduling mode
    task2.Mode = TaskMode.Automatic;

    Predecessor p = new Predecessor();
    p.PredecessorTask = task1;
    p.PredecessorType = PredecessorType.FinishToStart;
    task2.Predecessors.Add(p);

    //restore the manual mode
    task2.Mode = TaskMode.Manual;
}