GanttView for WPF | ComponentOne
Task Elements / Tasks
In This Topic
    Tasks
    In This Topic

    Any project plan revolves around tasks, which represent the amount of work to be done for accomplishing a set of goals. Tasks define work in terms of duration, dependencies (if any), and resource requirements.

    GanttView supports adding tasks to a project plan both at runtime as well as in code.

    At runtime, the control lets you add a task through the Add Task button available in the toolbar. Clicking the Add Task button opens the Task Information dialog to set basic properties of the task such as name, percent complete, start and finish dates, etc. You can also create new tasks by dragging the mouse in the chart view. Creating tasks through mouse drag with start date on a nonworking day such as Sunday or Saturday opens a dialog to resolve the conflict. The image below shows a Conflict Resolver dialog.

    Conflict Resolver

    The Conflict Resolver dialog resolves the conflict by providing users three options:    

    The image below shows tasks added to GanttView.

    Add task to GanttView

    In addition, GanttView supports several kinds of tasks such as milestones and summary tasks discussed in Milestone task and Project summary task sections.

    Creating and adding tasks in code

    In code, tasks can be created by defining an instance of the Task class and setting its basic properties such as name and duration through the Name and Duration properties. A task can be added to a GanttView through the Add method of the TaskCollection class. The following code illustrates creating a task, setting basic properties, and adding it to GanttView.

    'Creating a task and setting basic properties
    Dim t As New Task()
    t.Mode = TaskMode.Manual
    t.Name = "Requirement Gathering"
    t.Start = New DateTime(2016, 4, 5)
    t.Duration = 5
    
    'Adding task to GanttView
    gv.Tasks.Add(t)
    
    //Creating a task and setting basic properties
    Task t = new Task();
    t.Mode = TaskMode.Manual;
    t.Name = "Requirement Gathering";
    t.Start = new DateTime(2016, 4, 5);
    t.Duration = 5;
    
    //Adding task to GanttView
    gv.Tasks.Add(t);
    
    See Also