Predecessor and Successor Tasks

The PredTask and SuccTask properties exposed by the TaskLink class are used to define the predecessor and successor tasks for a TaskLink. Both of these properties read and write a Task object.

Working with Predecessor and Successor Tasks

To manage predecessor tasks in Microsoft Project:

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

Viewing predecessor tasks in Microsoft Project

checking task’s predecessor and successors in Microsoft Project

Getting Predecessor Tasks

The code sample given below displays the predecessor and successor task after traversing the task links in the project and writing the results to a console window.

 1// Create project instance
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"GetPredecessorSuccessorTasks.mpp");
 4    
 5// Display names of predecessor and successor tasks
 6    
 7{
 8    auto tsklnk_enumerator = (project1->get_TaskLinks())->GetEnumerator();
 9    decltype(tsklnk_enumerator->get_Current()) tsklnk;
10    while (tsklnk_enumerator->MoveNext() && (tsklnk = tsklnk_enumerator->get_Current(), true))
11    {
12        System::Console::WriteLine(System::String(u"Predecessor ") + tsklnk->get_PredTask()->Get(Tsk::Name()));
13        System::Console::WriteLine(System::String(u"Predecessor ") + tsklnk->get_SuccTask()->Get(Tsk::Name()));
14    }
15}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.