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.

A task link is created using the default constructor (TaskLink) which accepts three parameters:

  1. The first parameter defines the predecessor Task,
  2. the second parameter defines the successor Task and, finally,
  3. 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);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.