All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Tasks, Summaries, and Milestones

  • 4 minutes to read

The Gantt control automatically determines a task's type based on its duration and the presence of subtasks. The following task types are supported:

  • Task — a regular task that has a certain duration and does not have subtasks.

  • Summary task — a task that has subtasks. These tasks show combined information for their subtasks.

  • Milestone — a task with a zero duration. These tasks show important dates in the project.

The control also displays dependencies between tasks. A task can have a predecessor task that should be accomplished before the task can start. The figure below illustrates different task types and dependencies between them.

Task Captions

A task can have captions displayed inside, to the left, and to the right of the bar. Handle the GanttControl.CustomTaskDisplayText event to show captions.

The code below shows how to display captions to the left and to the right of the bars.

HashSet<int> criticalPathIds = new HashSet<int> { 1, 2, 3, 6, 7, 8, 10, 11, 13 };
ganttControl.CustomTaskDisplayText += (sender, e) => {
    int taskId = Convert.ToInt32(e.Node.GetValue("Id"));
    if(criticalPathIds.Contains(taskId)) {
        e.RightText = "High priority";
    }
    else {
        e.RightText = string.Empty;
        e.LeftText = "Normal priority";
    }
};
NOTE

Run the Gantt Code Examples demo to see the complete example.

Context Menus

When a user right-clicks a task's bar, the control can show a context menu. To populate the menu with commands, handle the GanttControl.TaskPopupMenuShowing event.

The code below shows how to populate the context menu with items.

using DevExpress.XtraEditors;
using DevExpress.XtraGantt;

private void ganttControl1_TaskPopupMenuShowing(object sender, GanttTaskPopupMenuShowingEventArgs e) {
    e.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Show Text", (ss, ee) => { XtraMessageBox.Show(e.Node.GetText()); }));
}

Tooltips

To show a tooltip for a task, handle GanttControl.TaskToolTipShowing event.

The code below shows a regular tooltip for a task.

using DevExpress.XtraGantt;

private void ganttControl1_TaskToolTipShowing(object sender, GanttTaskToolTipShowingEventArgs e) {
    e.Text = e.Node.GetText();
}

Draw a Task Manually

You can handle the following events to draw a task manually:

The code below shows how to indicate a critical path in the project.

HashSet<int> criticalPathIds = new HashSet<int> { 1, 2, 3, 6, 7, 8, 10, 11, 13 };
ganttControl.CustomDrawTask += (sender, e) => {
    int taskId = Convert.ToInt32(e.Node.GetValue("Id"));
    if(criticalPathIds.Contains(taskId)) {
        e.Appearance.BackColor = DXSkinColors.FillColors.Danger;
        e.Appearance.ProgressColor = DXSkinColors.FillColors.Danger;
    }
};
ganttControl.CustomDrawTaskDependency += (sender, e) => {
    int predecessorId = Convert.ToInt32(e.PredecessorNode.GetValue("Id"));
    int successorId = Convert.ToInt32(e.SuccessorNode.GetValue("Id"));
    if(criticalPathIds.Contains(predecessorId) && criticalPathIds.Contains(successorId)) {
        e.Appearance.BackColor = DXSkinColors.FillColors.Danger;
    }
};

The code below shows how to split a task's bar into two bars.

ganttControl.CustomDrawTask += (sender, e) => {
    if(e.Node.Id == 3) {
        e.Appearance.BackColor = DXSkinColors.FillColors.Danger;
        e.Appearance.ProgressColor = DXSkinColors.FillColors.Danger;
        TimeSpan offset = TimeSpan.FromHours(2);
        e.DrawShape(e.Info.StartDate + offset, e.Info.FinishDate - offset);
        e.DrawRightText();
        e.Handled = true;
    }
};
NOTE

Run the Gantt Code Examples demo to see the complete example.