event AddLink (LinkKey as String)
Occurs when the user links two bars using the mouse.

 TypeDescription 
   LinkKey as String A String expression that indicates the key of the link being added.  
The AddLink event notifies your application that the user links two bars using the mouse. The AddLink event occurs right after the control calls the AddLink method to add a link between the bars that the user selected. Use the AddLink method to add links by code.

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 Link property of the Items object to access the properties and options of the 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.

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

The sample checks whether the cell's value on the first column where the link starts is "Root", and if so, the style of the link is changed to a red thin link.


Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.