Defining Link Type
Contents
[
Hide
Show
]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.
Defining Link Type
To define link type in Microsoft Project:
- On the View menu, select More Views and then Task Entry Form.
- Double-click the desired task.
- Select the Predecessor tab.
Setting Link Type with Aspose.Tasks
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;
Getting Link Type with Aspose.Tasks
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}