Parent and Child Tasks

Tasks can be organized in a hierarchy. When a task has one or more tasks beneath it, they are referred to as parents. The tasks underneath are called children.

Working with Parent Tasks and Children

The Task class exposes classes that help you determine a:

Parent and Child Tasks in Microsoft Project

To declare a task as a parent or a child task in Microsoft Project:

  1. In the Task Entry form, select a task and click it.
  2. Select Outdent to turn a task into a parent, or,
  3. Select Indent to turn a task into a child.

Getting Parent and Child Tasks

The following examples show viewing parent and child tasks in a project using Aspose.Tasks.

 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"ParentChildTasks.mpp");
 4    
 5// Create a ChildTasksCollector instance
 6System::SharedPtr<ChildTasksCollector> collector = System::MakeObject<ChildTasksCollector>();
 7    
 8// Collect all the tasks from RootTask using TaskUtils
 9TaskUtils::Apply(project1->get_RootTask(), collector, 0);
10    
11// Parse through all the collected tasks
12    
13{
14    auto tsk1_enumerator = (collector->get_Tasks())->GetEnumerator();
15    decltype(tsk1_enumerator->get_Current()) tsk1;
16    while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
17    {
18        System::Console::WriteLine(tsk1->Get(Tsk::Name()));
19    }
20}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.