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

    GanttView allows you to define task dependencies such as task predecessors and task successors. A predecessor task is a task that precedes another activity or task which is also known as its successor task. This means that the start or finish date of a predecessor task determines the start or finish date of its successor task. When you assign a predecessor task in GanttView, the project automatically creates an arrow that points to the following task. If the predecessor type is not specified, the finish-to-start dependency is created by default.

    To create predecessors and successors, you can use Predecessors and Successors properties of the Task class, respectively. You can also specify the type of predecessor to be added by using PredecessorType property of Predecessor class. The PredecessorType property uses the PredecessorType enumeration to set the predecessor type to one of the following values:

    Dependency Dependency Type Description Example
    FSPredecessor Finish-to-start(FS) This dependency is created by default when you link two tasks in C1GanttView. The order in which you select the tasks treats the first as the predecessor, and the second as the successor. The work of task (B) can only start after all the work for task (A) is finished. For example, if you have two tasks, "Dig hole" and "Plant tree," the "Plant tree" task cannot begin until the "Dig hole" task is completed.
    SSPredecessor Start-to-start(SS) The dependent task can start at any time after the task that it depends on begins. This dependency is used when two tasks can overlap or be parallel. When you overlap the tasks, it will help reduce the total work time. For example, if Task A takes 7 days and Task B takes 10 days, then the overall time of the two tasks is only 10 days. The SS type does not require that both tasks begin at the same time. For example, if you have two tasks, “Planning phase” and “writing phase”, the “writing phase” task cannot begin until the “planning phase” begins.
    FFPredecessor Finish-to-finish (FF) The finish date of task (A) determines the finish date of task (B). This dependency is used when two tasks can overlap or be parallel. When you overlap the tasks it will help reduce the total work time. For example if Task A takes 7 days and Task B takes 10 days, then the overall time of the two tasks is only 10 days. For example, if you have two tasks, “set up inner tent” and “snap together poles”, the “snap together poles” (Task B) cannot be completed until the “set up inner tent” (Task A) is completed.
    SFPredecessor Start-to-finish(SF) The start date of Task (A) determines the finish date of the Task (B). This type of dependency usually occurs less frequently. For example, the book shelves for your construction project are built off-site. Two of the tasks in your project are “Wood delivery” and “Assemble book shelves”. The “assemble bookshelves” task cannot be completed until the “wood delivery” task begins.

    In GanttView, task dependencies can be visualized through lines connecting the dependent tasks as shown in the following image. Here, a Finish to Start type of dependency is created between the "Design" and "Development" tasks.

    Predecessor

    The following code example illustrates creating a predecessor task, and setting its dependence on another task and its type. Here, we create a predecessor task of FinishToStart type and set its dependency.

    C#
    Copy Code
    Task task1 = ganttView.Tasks.Search("Design");
    Task task2 = ganttView.Tasks.Search("Development");
    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;
        }
    

    Alternatively, the Predecessors tab available in the Task Information dialog can be used to create task dependencies at runtime.

    Besides this, the Predecessor class allows you to specify the lag time if there is an expected delay for something that must happen between two linked tasks by using Lag property. Specifying the lag time can be useful in the scenarios where you are expecting the delivery of materials. In such cases, you can specify the lag time in days, which is the default unit for lag time.