This topic shows how to delete a task at run time or in code. At run time, you can delete a task by clicking on the Delete button from the C1GanttView toolbar or you can use the index to programmatically specify the position of the new task.
To programmatically delete a task, complete the following:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Dim tasks As TaskCollection = ganttView.Tasks ' find NewTask Dim index As Integer = tasks.IndexOf("New Task") If index >= 0 Then ' delete and dispose the new task Dim t As Task = tasks(index) tasks.RemoveAt(index) t.Dispose() End If End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void btnDelete_Click(object sender, EventArgs e) { TaskCollection tasks = ganttView.Tasks; // find NewTask int index = tasks.IndexOf("New Task"); if (index >= 0) { // delete and dispose the new task Task t = tasks[index]; tasks.RemoveAt(index); t.Dispose(); } } |