Creating Task Links
Contents
[
Hide
Show
]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 C++ 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
2System::SharedPtr<Project> project1 = System::MakeObject<Project>();
3System::SharedPtr<Task> pred = project1->get_RootTask()->get_Children()->Add(u"Task 1");
4System::SharedPtr<Task> succ = project1->get_RootTask()->get_Children()->Add(u"Task 2");
5
6// Links tasks
7System::SharedPtr<TaskLink> link = project1->get_TaskLinks()->Add(pred, succ);