GanttView allows you to insert a task at a specific index. You can insert a task using code and 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.
Below code snippet shows how you can insert a task at a specific index programmatically:
C# |
Copy Code
|
---|---|
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; } |