Defining Link Type
Task links represent logical relationships between two tasks in a project schedule. Each link has a type that determines how the start and finish dates of the linked tasks are constrained relative to each other.
In Aspose.Tasks for .NET, the LinkType property of the TaskLink class is used to get or set the relationship type. The property accepts values from the TaskLinkType enumeration.
Task Link Types in Microsoft Project
Microsoft Project supports four standard dependency types:
- Finish-to-Start (FS) – The successor task cannot start until the predecessor finishes. (default)
- Start-to-Start (SS) – The successor cannot start until the predecessor starts.
- Finish-to-Finish (FF) – The successor cannot finish until the predecessor finishes.
- Start-to-Finish (SF) – The successor cannot finish until the predecessor starts.
These same values are available in Aspose.Tasks via the TaskLinkType
enumeration.
Defining Link Type in Microsoft Project
To set the link type manually in Microsoft Project:
- From the View menu, select More Views and then Task Entry Form.
- Double-click the desired task.
- Open the Predecessor tab.
- Select the desired link type.
Working with Link Types in Aspose.Tasks
Setting Link Type
The following example shows how to define a “Start-to-Start” (SS) link type between two tasks. By default, links are created as “Finish-to-Start” (FS).
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// Link tasks with link type set to Start to Start
7TaskLink link = project.TaskLinks.Add(pred, succ);
8link.LinkType = TaskLinkType.StartToStart;
Getting Link Type
The following example demonstrates how to read the link types of all task links in a project and output them to the console.
1Project project = new Project("New Project.mpp");
2
3foreach (TaskLink taskLink in project.TaskLinks)
4{
5 Console.WriteLine(taskLink.LinkType.ToString());
6}
Conclusion
Task link types are a fundamental part of project scheduling. By using the LinkType
property of the TaskLink
class in Aspose.Tasks for .NET, you can create, modify, and analyze dependencies between tasks programmatically. This makes it possible to automate project planning and ensure that task relationships remain consistent across complex schedules.