| GanttView for WinForms Task-Based Help > Moving a Task |
You can move a task at run time using the up or down arrows located on the C1GanttView toolbar or you can move tasks programmatically using the RemoveAt and Insert methods.
After clicking the Move Task Up button the Editing phase task is moved up one position.
To move a task programmatically, complete the following:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub btnMove_Click(sender As Object, e As EventArgs)
Dim tasks As TaskCollection = ganttView.Tasks
Dim index As Integer = tasks.IndexOf("New Task")
If index > 0 Then
Dim t As Task = tasks(index)
tasks.RemoveAt(index)
tasks.Insert(0, index - 1)
End If
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void btnMove_Click(object sender, EventArgs e)
{
TaskCollection tasks = ganttView.Tasks;
int index = tasks.IndexOf("New Task");
if (index > 0)
{
Task t = tasks[index];
tasks.RemoveAt(index);
tasks.Insert(0, index - 1);
}
}
|
|