All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
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.

Split Tasks

  • 4 minutes to read

The WinForms Gantt Control supports split tasks — tasks with interruptions.

If a user moves the mouse pointer above a partially completed task, the pointer changes to a four-way arrow. The user can drag the uncompleted segment to split the task. The user can split a task into as many sections as needed.

If a task is split, the user can resize and move all of its segments. If the user drags the first segment, the control moves all segments. Any other segment can be moved separately.

TIP

Run the following demo to see split tasks in action: Startup Plan module in the XtraGantt GanttDemo. To view source code, click Open Solution in the ribbon.

Data Source

To allow the control or a user to split tasks, assign a data source that contains splits to the SplitTaskSource property. The data record contains information about the split: the task, the split start date, and the duration. The GanttControl.SplitTaskMappings property specifies the following mappings:

ganttControl1.SplitTaskMappings.StartDateFieldName = "StartDate";
ganttControl1.SplitTaskMappings.DurationFieldName = "Duration";
ganttControl1.SplitTaskMappings.KeyFieldName = "UID";

List<TaskSplitInfo> splitInfo = new List<TaskSplitInfo>();
splitInfo.Add(new TaskSplitInfo() {UID = "8", StartDate = tasks[8].StartDate + TimeSpan.FromHours(2), Duration = TimeSpan.FromHours(8)});
splitInfo.Add(new TaskSplitInfo() {UID = "9", StartDate = tasks[9].StartDate + TimeSpan.FromHours(5), Duration = TimeSpan.FromDays(1)});
splitInfo.Add(new TaskSplitInfo() { UID = "10", StartDate = tasks[10].StartDate + TimeSpan.FromHours(4), Duration = TimeSpan.FromHours(4) });
splitInfo.Add(new TaskSplitInfo() { UID = "10", StartDate = tasks[10].StartDate + TimeSpan.FromDays(2) + TimeSpan.FromHours(2), Duration = TimeSpan.FromHours(4) });
ganttControl1.SplitTaskSource = splitInfo;

public class TaskSplitInfo {
    public string UID { get; set; }
    public DateTime StartDate { get; set; }
    public TimeSpan Duration { get; set; }
}

A task has a start date, finish date, and duration. To specify a task's location on the time scale, you only need two of them: start and finish, or start and duration. The control automatically calculates the unspecified parameter (duration or finish date) when tasks are loaded from the data source. See the following help topic for more information on how to specify the data fields that contain corresponding values: Data Source.

The control calculates the unspecified parameter as follows:

  • If you have specified the start and finish dates — task splits reduce the duration but do not change the finish date
  • If you have specified the start date and duration — task splits postpone the finish date but do not change the duration

Note that after tasks are loaded (finish dates/durations are calculated), the control can only update the finish date (but not the duration) when a user increases or decreases a task's split.

Automatic Scheduling

If the ScheduleMode option is set to Auto, the control reschedules a task once a change is made, and can split the task. For example, if a task is partially completed and should be postponed due to rescheduling, the control automatically splits the completed and uncompleted parts of the task.

If the ScheduleMode option is set to Manual, users can split partially completed tasks, but the control does not split tasks when changes are made.

If you disable the AllowSplitTasks option, the control does not split tasks when changes are made, and does not permit users to split tasks.

Set Splits in Code

To get and set splits in code, use the following methods: