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.

Microsoft Project supports four standard dependency types:

These same values are available in Aspose.Tasks via the TaskLinkType enumeration.

To set the link type manually in Microsoft Project:

  1. From the View menu, select More Views and then Task Entry Form.
  2. Double-click the desired task.
  3. Open the Predecessor tab.
  4. Select the desired link type.

defining task links

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;

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.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.