Defining Link Type

The LinkType property exposed by the TaskLink class is used to retrieve or define the type of link between two tasks. It reads and writes one of the values defined by the TaskLinkType enumeration type.

To define link type in Microsoft Project:

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

defining task links

The code samples below set a link type as “Start-to-Start”, the default link type is “Finish-to-Start”.

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 code samples below display link types by traversing the task links in the project and printing the result to a console window.

1Project project = new Project("New Project.mpp");
2
3foreach (TaskLink taskLink in project.TaskLinks)
4{
5    Console.WriteLine(taskLink.LinkType.ToString());
6}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.