Parent and Child Tasks
In Microsoft Project, tasks are often organized hierarchically to represent work breakdown structures (WBS).
- A parent task groups and summarizes the work of its subtasks.
- A child task is indented beneath another task and contributes to its parent’s duration, cost, and progress.
Aspose.Tasks for .NET lets developers easily access and manipulate parent–child relationships programmatically.
Working with Parent Tasks and Children
The Task class provides access to hierarchical relationships:
Parent Type: Task object Purpose: Returns the parent task of the current task.
Children Type: Collection of Task objects Purpose: Returns the list of child tasks associated with the current task.
These properties allow developers to traverse the task hierarchy in both directions.
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 C# example demonstrates how to retrieve parent and child tasks from a project:
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}
Key Notes
- A task can be both a parent and a child at the same time (e.g., a mid-level task).
- Parent tasks typically act as summary tasks, aggregating cost, work, and duration from child tasks.
- Hierarchical structures are essential for project reporting and scheduling clarity.
FAQ
Q: Can a task have multiple parents?
- No. Each task can only belong to a single parent, ensuring a clear hierarchical structure.
Q: Do parent tasks affect scheduling directly?
- Parent tasks summarize information but do not enforce scheduling rules — dependencies still control scheduling.
Q: Are parent–child relationships preserved in MPP and XML formats?
- Yes. Aspose.Tasks ensures hierarchy consistency across supported Microsoft Project formats.