GanttView allows you to insert a task at a specific index. You can insert a task using code as well as at run time.
To insert a task at run time, follow the steps given below:
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:
| C# | 
                         
                            コードのコピー
                         
                     | 
                
|---|---|
                        
TaskCollection tasks = c1GanttView1.Tasks;
        int index = tasks.IndexOf("Task 2");
        if (index >= 0)
        {
            // 新しいタスクを作成します。
            Task t = new Task();
            tasks.Insert(index, t);
            t.Mode = TaskMode.Automatic;
            t.Name = "New Task";
            t.Duration = 3;
        }
                     | 
                |