GanttView for WinForms
タスクの挿入
GanttView の使用 > タスク操作 > タスクの挿入

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:

  1. グリッドの タスク名 フィールドで、タスクリストの末尾にタスク名を入力します。
  2. ENTER キーを押すと、新しいタスクがグリッドに表示されます。
    This adds a new task in the task grid.

コードでタスクを挿入する

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;
        }