[]
        
(Showing Draft Content)

Task Resources

You can assign resources to a specific task first by creating the resource and then assigning the resource to the specific task. Resources can be created at design time, run time, or programmatically. In GanttView, the collection of resources is represented by the ResourceRefCollection class. You can add a resource by using the ResourceRefs property of the Task class. You can also set the name and cost of the resource using the Name and Cost properties of the Resource class respectively. Other than this, you can also specify the type of resource to be added by using the ResourceType property of the Resource class, which uses the ResourceType enumeration to set the resource type to one of the following values:

  • Work: A work resource is anyone or anything that is needed to complete a project such as people and machines. Typically, resources are people involved in your project irrespective of whether they are assigned tasks or not. Equipment can include web servers or computers that have special software needs to accomplish certain tasks. Work resources need time (hours, day or weeks) to finish the task.
  • Material: A material resource includes things that are consumed by a task. They don’t depend on the total work amount or duration of the task.
  • Cost: A cost resource is anything that doesn’t depend on the total work amount or duration of the task. This type of resource is needed in your project to analyze your costs.

Below code snippet shows how you can add a resource to your task in the GanttView control.

// Add the new Resource object
Resource r1 = new Resource();
r1.Name = "Resource 1";
r1.Cost = 300m;
c1GanttView1.Resources.Add(r1);
// add a resource reference to the task
ResourceRef rRef = new ResourceRef();
rRef.Resource = r;
rRef.Amount = 0.5;
Task1.ResourceRefs.Add(rRef);