Version

Configuring Task Dependencies

Topic Overview

Purpose

This topic explains how to configure tasks dependencies using the xamGantt™ control.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic describes how the xamGantt control can be bound to data via Project property.

Configuring Tasks Dependencies Configuration Summary

Tasks dependencies configuration summary chart

The following table lists possible options for configuring tasks dependencies in the xamGantt control. Additional details follow later in this topic.

Configurable aspect Details Property

Specifying a task’s predecessors

Returns or sets a string representing the task predecessors ID, link type and lead/lag time.

Specifying a task’s predecessors

Returns a collection of ProjectTaskDependency objects representing the task predecessors.

Specifying a task’s successors

Returns or sets a string representing the task successors ID, link type and lead/lag time.

Specifying task’s successors

Returns a collection of ProjectTaskDependency objects representing the task successors.

Specify a dependency line type

Returns or sets a value of type ProjectTaskDependencyLineType indicating the type of line connecting dependent tasks.

Supported dependency link types:

Link type notation in editor Link type Description

FS

Finish To Start

If not otherwise specified this is the default link type.

The successor’s Start date is dependent upon the predecessor’s Finish date.

FF

Finish To Finish

The successor’s Finish date is dependent upon the predecessor’s Finish date.

SF

Start To Finish

The successor’s Finish date is dependent upon the predecessor’s Start date.

SS

Start To Start

The successor’s Start date is dependent upon the predecessor’s Start date.

Specifying Tasks Dependencies Using Predecessors and Successors Collections

Overview

The xamGantt control provides functionality for creating dependency links between tasks within a project and supports the link types available in Microsoft Project 2010. You can specify a lead and lag time of the dependency as well.

You create tasks dependencies programmatically using collections of tasks’ predecessors and successors. Use the ProjectTask Predecessors and Successors properties to create a collection of ProjectTaskDependency objects.

The Successors and Predecessors collections expose two overload methods of the Add method.

The first one takes as parameters ProjectTask and ProjectTaskLinkType.

The second one takes as parameters ProjectTask, ProjectTaskLinkType and ProjectDuration.

See the xamGantt Columns Editing topic for more information about tasks dependencies, their string representation and acceptable duration formats.

Property settings

The following table maps the tasks dependencies configuration to property settings.

In order to: Use this property: And method: And set it to:

Set a task’s successors collection

Add

Set a task’s predecessors collection

Add

Example

The code example below demonstrates how to create tasks dependencies using the Predecessors and Successors collections :

In C#:

ProjectTask firstTask = this.gantt.Project.RootTask.Tasks[0];
// Setting two dependencies for a task
// firstTask.Tasks[0].SuccessorsIdText = "3,4";
firstTask.Tasks[0].Successors.Add(firstTask.Tasks[1]);
firstTask.Tasks[0].Successors.Add(firstTask.Tasks[2]);
// Setting Finish-to-Start dependency
// and a lead time of 50% between dependent tasks
// The overlap between the tasks is 50% percent of the predecessor task duration
// firstTask.Tasks[1].SuccessorsIdText = "4FS-50%";
firstTask.Tasks[1].Successors.Add(firstTask.Tasks[2], ProjectTaskLinkType.FinishToStart, ProjectDuration.FromFormatUnits(-50, ProjectDurationFormat.Percent));
// Setting a lead time of two days
// firstTask.Tasks[3].PredecessorsIdText = "4FS-2 days";
firstTask.Tasks[3].Predecessors.Add(firstTask.Tasks[2], ProjectTaskLinkType.FinishToStart, ProjectDuration.FromFormatUnits(-2, ProjectDurationFormat.Days));
// Setting delay (lag time) of 1 day between dependent tasks
// firstTask.Tasks[4].PredecessorsIdText = "5SS+1d";
firstTask.Tasks[4].Predecessors.Add(firstTask.Tasks[3], ProjectTaskLinkType.StartToStart, ProjectDuration.FromFormatUnits(1, ProjectDurationFormat.Days));

In Visual Basic:

Dim firstTask As ProjectTask = Me.gantt.Project.RootTask.Tasks(0)
' Setting two dependencies for a task
' firstTask.Tasks[0].SuccessorsIdText = "3,4";
firstTask.Tasks(0).Successors.Add(firstTask.Tasks(1))
firstTask.Tasks(0).Successors.Add(firstTask.Tasks(2))
' Setting Finish-to-Start dependency
' and a lead time of 50% between dependent tasks
' The overlap between the tasks is 50% percent of the predecessor task duration
' firstTask.Tasks[1].SuccessorsIdText = "4FS-50%";
firstTask.Tasks(1).Successors.Add(firstTask.Tasks(2), ProjectTaskLinkType.FinishToStart, ProjectDuration.FromFormatUnits(-50, ProjectDurationFormat.Percent))
' Setting a lead time of two days
' firstTask.Tasks[3].PredecessorsIdText = "4FS-2 days";
firstTask.Tasks(3).Predecessors.Add(firstTask.Tasks(2), ProjectTaskLinkType.FinishToStart, ProjectDuration.FromFormatUnits(-2, ProjectDurationFormat.Days))
' Setting delay (lag time) of 1 day between dependent tasks
' firstTask.Tasks[4].PredecessorsIdText = "5SS+1d";
firstTask.Tasks(4).Predecessors.Add(firstTask.Tasks(3), ProjectTaskLinkType.StartToStart, ProjectDuration.FromFormatUnits(1, ProjectDurationFormat.Days))

Specifying Tasks Dependencies Using PredecessorsIdText and SuccessorsIdText Properties

Overview

In order to set a task’s dependencies, use the ProjectTask SuccessorsIdText and SuccessorsIdText properties. These properties accept a string representation of the dependency including dependent task ID, link type and lag or lead-time.

See the xamGantt Columns Editing topic for more information about tasks dependencies and their string representation.

Property settings

The following table maps the task dependencies configuration to property settings.

In order to: Use this property: And set it to:

Set a task successors

string

Set a task predecessors

string

Example

The screenshot below illustrates how to establish task dependencies using the following code example. Observe in the xamGantt chart area uses dependencies links to represent the defined dependencies.

Configuring Task Dependencies 1.png

In C#:

ProjectTask firstTask = this.gantt.Project.RootTask.Tasks[0];
// Setting two dependencies for a task
firstTask.Tasks[0].SuccessorsIdText = "3,4";
// Setting Finish-to-Start dependency
// and a lead time of 50% between dependent tasks
// The overlap between the tasks is 50% percent of the predecessor task duration
firstTask.Tasks[1].SuccessorsIdText = "4FS-50%";
// Setting a lead time of two days
firstTask.Tasks[3].PredecessorsIdText = "4FS-2 days";
// Setting delay (lag time) of 1 day between dependent tasks
firstTask.Tasks[4].PredecessorsIdText = "5SS+1d";

In Visual Basic:

Dim firstTask As ProjectTask = Me.gantt.Project.RootTask.Tasks(0)
' Setting two dependencies for a task
firstTask.Tasks(0).SuccessorsIdText = "3,4"
' Setting Finish-to-Start dependency
' and a lead time of 50% between dependent tasks
' The overlap between the tasks is 50% percent of the predecessor task duration
firstTask.Tasks(1).SuccessorsIdText = "4FS-50%"
' Setting a lead time of two days
firstTask.Tasks(3).PredecessorsIdText = "4FS-2 days"
' Setting delay (lag time) of 1 day between dependent tasks
firstTask.Tasks(4).PredecessorsIdText = "5SS+1d"

Related Topics

The following topics provide additional information related to this topic.

Topic Purpose

The topics in this group explain the xamGantt ProjectTask class, its configurable aspects and the main features it provides.