One of the greatest features of GanttView is the ability to add a Summary Task. The task list can be broken down into Summary Tasks to make it appear more ordered and understandable. Summary tasks are usually created by indenting and outdenting the project's tasks to create an outline of the summary tasks and subtasks.
A summary task is an abstract task and some of their property values depend on all their children’s properties. When a child changes its property values, its parent and ancestor task’s properties will also be updated like the following:
You can create task summary by using the ProjectSummary property of the C1GanttView class. Additionally you can also add children to the summary task by setting its OutlineParent and OutlineParentID properties.
Below code snippet shows how you can add a summary task in the GanttView control.
C# |
Copy Code
|
---|---|
//Add Summary Task Task SummaryTask = new Task(); SummaryTask.Mode = TaskMode.Automatic; SummaryTask.Name = "Summary Task"; SummaryTask.SetFieldValue("Country", "SummaryTask"); this.c1GanttView1.ProjectSummary = SummaryTask; c1GanttView1.Tasks.Add(SummaryTask); |
To delete a summary task, you can use the RemoveAt method of the Collection class by specifying its index. When you delete a summary task, its children also get deleted. If the deleted task is the last child of a summary task, that summary task will become a regular task.
Use the below code to delete the summary task.
C# |
Copy Code
|
---|---|
//Delete Summary task TaskCollection tasks = c1GanttView1.Tasks; // find SummaryTask int index = tasks.IndexOf("SummaryTask"); if (index >= 0) { // delete and dispose the new task Task t = tasks[index]; tasks.RemoveAt(index); t.Dispose(); } |
You can add children to a summary task and can easily expand or collapse the summary task to hide or show the children. To add a children to a summary task, you can use the OutlineParentID property of the Task class.
Below code snippet shows how you can add a children to a summary task.
C# |
Copy Code
|
---|---|
//Add Child task Task ChildTask = new Task(); ChildTask.Name = "Child Task"; ChildTask.Mode = TaskMode.Automatic; ChildTask.PercentComplete = 0.50; ChildTask.Duration = 6; ChildTask.DurationUnits = DurationUnits.Days; ChildTask.SetFieldValue("Country", "China"); ChildTask.OutlineParentID = SummaryTask.ID; ChildTask.BarStyles.Add(automaticStyle); c1GanttView1.Tasks.Add(ChildTask); |
You can move a task summary up or down at run time by clicking the Move Task Up or Move Task Down button. Moving a summary task moves all its children along with it. If the previous or next task before is the summary task, the moved task gets adopted as a new child by that task. Otherwise, the moved task gets adopted by the old neighbor’s parent.
You can change the outline structure by using Indent Task and Outdent Task buttons on the toolstrip. If the indented or outdented task is a summary task, all its children gets structured along with the summary task.
The indented task gets adopted by the upper nearest task that has the same outline level with it. If the parent task is regular task, then it becomes a summary task after indenting the selected task.
The outdented task gets adopted as a new child of its grandparent. If it is the last child of its parent before outdent, after that, the old parent becomes a regular task.
You can show or hide project summary tasks by clicking the Show Project Summary button from the toolstrip. By default, this task is hidden from the Gantt Chart.
To represent multiple tasks on the Project Summary Task bar, set the ReflectOnSummary property of the Task class to True for the tasks that you want to be shown on the Project Summary Task bar. The tasks are then represented on the bar through markers or outlines that differentiate multiple tasks. Other than this, you can also select the ReflectOnSummary bar option for the tasks at design time on the Task Information dialog box.