[]
        
(Showing Draft Content)

Insert Task

GanttView allows you to insert a task at a specific index. You can insert a task using code as well as at run time.

Insert Task at run time

To insert a task at run time, follow the steps given below:

  1. In the Task Name field of the grid, type a task name at the end of the task list.
  2. Press ENTER and the New Task item will appear in the grid.
    This adds a new task in the task grid.

Insert Task programmatically

You can insert a task at specific position using Insert method of the Collection class by passing the index as a parameter.

The below code snippet shows how you can insert a task at a specific index programmatically:

TaskCollection tasks = c1GanttView1.Tasks;
        int index = tasks.IndexOf("Task 2");
        if (index >= 0)
        {
            // create a new task
            Task t = new Task();
            tasks.Insert(index, t);
            t.Mode = TaskMode.Automatic;
            t.Name = "New Task";
            t.Duration = 3;
        }