method G2antt.PutRes (ResHandle as Long, Type as PutResEnum)
The PutRes method associates an eXG2antt (Source) control with another eXG2antt (Target) control, using the Items.ItemBar(exBarResources).

TypeDescription
ResHandle as Long A Handle expression being returned by the ResHandle property.
Type as PutResEnum A PutResEnnum expression that indicates whether the control loads or saves the bar's resources to or from another control.
The eXG2antt component (Target) can display resources being used by another eXG2antt component ( Source ). The PutRes method associates an eXG2antt (Source) control with another eXG2antt (Target) control, using the Items.ItemBar(exBarResources). The Source displays the bar and the resources to be used by each bar, while the Target shows the Resources being used by each bar found in the Source. A resource is identified by a name like R1, or a name followed by its usage in percent, like R1[20%], which indicates that the bar uses the resource R1 on 20% of its full capacity.

In order to use the PutRes method the Source control must:

Bellow you can find: 

The following sample shows the bar's allocation of resources: ( for instance the Task 1 uses the R1, Task 2 uses the R1 and R2, while Task 3 uses R2 on 60% and R3 on 39%, and so on )

(source, picture 1)

while the next picture shows the resource usage being taken from the first picture ( for instance, the R1 is being used by Task 1 and Task 2, R2 is used by Task 2, Task 3 on 60% and Task 4, and so on ) :

 

(target, picture 2)

The Source ( picture 1 ) is the original control  that displays your activities / bars. Use the Source.PutRes( Target.ResHandle, exPutResSave ) to update the bar's resources in a Source control, from a Target control. IN a Source control, you can use the following properties to specify the usage of resources.

You can use the exBarCaption to display the bar's resources using the <%=formula%> format, like in the following VB sample:

With G2antt1.Chart.Bars("Task")
    .Def(EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarCaption) = "<%=%" & EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarResources & "%>"
    .Def(EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarHAlignCaption) = 18
End With

In other words, the sample allows you to display the bar's exBarResources property as shown bellow:

The set exBarResources property could be used in the following format based on the first character as listed: 

  • If the first character is +(plus), the rest of the expression indicates the resources to be assigned to the current bar. For instance, if the current bar has the exBarResources property as "R1,R2" , and we call set exBarResources as "+R3", it means that the R3 is added to the bar's resources, and so the new exBarResources property is "R1,R2,R3".
  • If the first character is -(minus), the rest of the expression indicates the resources to be removed from the current bar. For instance, if the current bar has the exBarResources property as "R1,R2" , and we call set exBarResources as "-R2", it means that the R2 is removed from the bar's resources, and so the new exBarResources property is "R1".
  • If no +,- character, the new expression replaces the exBarResources property. For instance, if the current bar has the exBarResources property as "R1,R2" , and we call set exBarResources as "R3,R4", it means that the new exBarResources property is "R3,R4".
With G2antt1.Chart.Bars("Task")
    .Def(exBarResourceFormat) = "`<b>` + name + `</b><font ;5><fgcolor=404040>` + (percent = 1 ? `` : (round(100*percent) format ``) + `%` ) + `</fgcolor></font>`"
    .Def(EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarCaption) = "<%=%" & EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarResourcesFormat & "%>"
    .Def(EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarHAlignCaption) = 18
End With

In other words, the sample allows you to display the bar's exBarResources property as shown bellow:

 

The Target ( picture 2 ) is the control that displays the Resources column, where all resources found are being added line by line, and its usage on items. Use the Target.PutRes(Source.ResHandle, exPutResLoad) to update the Target control from a Source control. IN a Target control, you can use the following properties to specify the usage of resources.

Private Sub G2antt1_BarResizing(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    With G2antt1.Items
        .ItemBar(Item, Key, EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarEffort) = .ItemBar(Item, Key, EXG2ANTTLibCtl.ItemBarPropertyEnum.exBarPercent)
    End With
End Sub

Now, let's display the Resources of the Source into the Target control ( Target.PutRes Source.ResHandle, exPutResLoad )

First step is specifying the ItemBar(exBarResources) property in the Source control. If the Source control has no bars with the ItemBar(exBarResources) property, no resource will be displayed in the target control. 

The following sample adds a column and two activities/bars, with allocated resources:

With Source
    .BeginUpdate
    With .Chart
        .FirstVisibleDate = #1/1/2001#
        With .Bars("Task")
            .Def(exBarHAlignCaption) = 18
            .Def(exBarCaption) = "<%=%49%>"
        End With
    End With
    .Columns.Add "Tasks"
    Dim h As Long
    With .Items
        h = .AddItem("Task 1")
        .AddBar h, "Task", #1/6/2001#, #1/12/2001#, "K1"
        .ItemBar(h, "K1", exBarResources) = "R1,R2"
        h = .AddItem("Task 2")
        .AddBar h, "Task", #1/4/2001#, #1/14/2001#, "K2"
        .ItemBar(h, "K2", exBarResources) = "R2[75%],R3"
    End With
    .EndUpdate
End With

and the Source should show as:

The second step is calling the PutRes method as follows:

Target.PutRes Source.ResHandle, exPutResLoad

and the Target should show as:

The PutRes(exPutResLoad) method updates the Target as follows:

 As the Target control can display multiple activities/bars on the same row/item/resource we should make a few adjustments on the Target control as:
With Target
    With .Chart
        .FirstVisibleDate = Source.Chart.FirstVisibleDate
        With .Bars.Add("Task%Progress")
            .OverlaidType = exOverlaidBarsStack Or exOverlaidBarsStackAutoArrange
            .Shortcut = "Task"
        End With
    End With
End With
The code, defines the "Task" bar to display "Progress", and to be stacked on the same row. This code, should be called once, before calling the PutRes and so the Target should show as:

Now, let's display the histogram of Resources usage in the Target control The Target control represents a task into it's histogram only if: The control's histogram uses: The first step is to change the Target's code initialization as follows:
With Target
    With .Chart
        .FirstVisibleDate = Source.Chart.FirstVisibleDate
        With .Bars.Add("Task%Progress")
            .OverlaidType = exOverlaidBarsStack Or exOverlaidBarsStackAutoArrange
            .Shortcut = "Task"
            .HistogramPattern = exPatternShadow
            .HistogramCriticalColor = .HistogramColor
            .ShowHistogramValues = "1"
        End With
        .HistogramVisible = True
        .HistogramView = exHistogramCheckedItems
        .HistogramHeight = 164
    End With
    With .Columns.Add("Names")
        .Key = "Resources"
        .Def(exCellHasCheckBox) = True
    End With
End With
The code does the following: The second step is updating the exBarEffort with exBarPercent value, when the BarResizing event occurs:
Private Sub Target_BarResizing(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    With Target.Items
        .ItemBar(Item, Key, exBarEffort) = .ItemBar(Item, Key, exBarPercent)
    End With
End Sub
The third step is calling the PutRes method as follows:
Target.PutRes Source.ResHandle, exPutResLoad
and the Target should show as:

Now, let's make the histogram displays cumulative-percents instead: So, the first step is to change the Target's code initialization as follows:
With Target
    With .Chart
        .FirstVisibleDate = Source.Chart.FirstVisibleDate
        With .Bars.Add("Task%Progress")
            .OverlaidType = exOverlaidBarsStack Or exOverlaidBarsStackAutoArrange
            .Shortcut = "Task"
            .HistogramType = exHistOverAllocation Or exHistCumulative
            .HistogramCumulativeColor(1) = RGB(255, 255, 0)
            .HistogramColor = RGB(196, 196, 196)
            .HistogramPattern = exPatternShadow
            .ShowHistogramValues = "value > 100 ? 255 : 1"
        End With
        .HistogramVisible = True
        .HistogramView = exHistogramCheckedItems
        .HistogramHeight = 96
    End With
    With .Columns.Add("Names")
        .Key = "Resources"
        .Def(exCellHasCheckBox) = True
    End With
End With
The code does the following: The second step is calling the PutRes method as follows:
Target.PutRes Source.ResHandle, exPutResLoad
The third step is updating the exBarEffort after PutRes call as follows:
With Target.Items
    Dim Item As Variant
    For Each Item In Target.Items
        Dim Key As Variant
        Key = .FirstItemBar(Item)
        While Not IsEmpty(Key)
            .ItemBar(Item, Key, exBarEffort) = .ItemBar(Item, Key, exBarPercent) * .ItemBar(Item, Key, exBarDuration)
            Key = .NextItemBar(Item, Key)
        Wend
    Next
End With
The code enumerates all the bars in the Target control, and changes the exBarEffort property to be exBarPecent of exBarDuration. This code is required as for exHistOverAllocation type the work-load for a task is computed as ItemBar(exBarEffort) / ItemBar(exBarDuration). The work-load for the task is the work effort / task duration. (i.e. If item.exBarEffort = 1 and the bar's length is 10 days, then the work-load = 0.1 or 10%). We also, should apply the change of exBarEffort when the BarResizing event, such as:
Private Sub Target_BarResizing(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    With Target.Items
        .ItemBar(Item, Key, exBarEffort) = .ItemBar(Item, Key, exBarPercent) * .ItemBar(Item, Key, exBarDuration)
    End With
End Sub
and the Target should show as:

Now, let's update the Source control from the Target control (Source.PutRes Target.ResHandle, exPutResSave): The following code should be called to synchronize the Start/End/Resource-Usage from the Target to the Source
Source.PutRes Target.ResHandle, exPutResSave
The PutRes(exPutResSave) method updates the Source control as follows: