Parent and Child Tasks
Contents
[
Hide
Show
]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: determines that a task is a parent task. Accepts and returns a Task object.
- Children: determines that a task is a child task. Accepts and returns an array list of Task objects.
Parent and Child Tasks in Microsoft Project
To declare a task as a parent or a child task in Microsoft Project:
- In the Task Entry form, select a task and click it.
- Select Outdent to turn a task into a parent, or,
- 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.
1Project project = new Project("New Project.mpp");
2
3// Create a ChildTasksCollector instance
4ChildTasksCollector collector = new ChildTasksCollector();
5
6// Collect all the tasks from RootTask using TaskUtils
7TaskUtils.Apply(project.RootTask, collector, 0);
8
9// Parse through all the collected tasks
10foreach (Task task in collector.Tasks)
11{
12 Console.WriteLine(task.Get(Tsk.Name));
13}