ComponentOne GanttView for WinForms
Working with GanttView / Task Elements / Task Resources
In This Topic
    Task Resources
    In This Topic

    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:

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

    C#
    Copy Code
    // 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);