Creating Task Links
Microsoft Project allows to link tasks based on the relationship between these. A task link is defined by a predecessor and a successor task. Task links can be of different types including FinishToFinish, FinishToStart, StartToFinish, and StartToStart. Aspose.Tasks for .NET API provides users with the capability to define task links in their project using the TaskLink class.
Creating a Task Link
A task link is created using the default constructor (TaskLink) which accepts three parameters:
- The first parameter defines the predecessor Task,
- the second parameter defines the successor Task and, finally,
- the third parameter defines the task link type from values specified by the TaskLinkType enumeration type. This is an optional parameter.
The following example creates a link between two tasks with Task1 as predecessor.
1// Create new project and add tasks 2Project project = new Project(); 3Task pred = project.RootTask.Children.Add("Task 1"); 4Task succ = project.RootTask.Children.Add("Task 2"); 5 6// Links tasks 7TaskLink link = project.TaskLinks.Add(pred, succ);