![]() | Type | Description | ||
| LinkKey as String | A String expression that indicates the key of the link being added. |
The AddLink event may occur only if the AllowLinkBars property is True. The LinkKey parameter indicates the key of the newly added link. Use the RemoveLink method to remove the link, if you don't need certain links to be added. The FirstLink property retrieves the key of the first link in the chart. Use the NextLink property to retrieve the key of the next link, in the chart. Use these properties to enumerate the link in the control. Use the CellValue property to access the cell's value.
In the following screen shot shows the bars before linking and grouping:

In the following screen shot shows the bars after linking and grouping, as the bar 1 is linked to bar 2, and bar 2 to 3.

In the following screen shot shows the bars once the bar 2 is moved to the right:

The following VB sample groups the linked bars:
Private Sub G2antt1_AddLink(ByVal LinkKey As String)
With G2antt1.Items
.Link(LinkKey, exLinkGroupBars) = GroupBarsOptionsEnum.exPreserveBarLength + GroupBarsOptionsEnum.exFlexibleInterval + GroupBarsOptionsEnum.exIgnoreOriginalInterval
End With
End Sub
The following VB sample changes the style of the link if certain condition is met ( in this sample, the cell on the first column is called "Root" ):
Private Sub G2antt1_AddLink(ByVal LinkKey As String)
With G2antt1.Items
If .CellValue(.Link(LinkKey, exLinkStartItem), 0) = "Root" Then
.Link(LinkKey, exLinkStyle) = exLinkSolid
.Link(LinkKey, exLinkWidth) = 2
.Link(LinkKey, exLinkColor) = RGB(255, 0, 0)
End If
End With
End Sub