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 AllowLink event is called before adding the link, so you can prevent adding new links between specified type of bars. The AddLink event occurs right after the control calls the AddLink method that adds a link between the bars that the user selected. By default, the control provides keys as "Link1", "Link2", ... You can use the Link(exLinkKey) property to change the default key of the link. If the control supports Undo/Redo, you can use the UndoRemoveAction method to remove a specific action from the undo queue.  For instance, if you do not need to record RemoveLink during the AddLink event, you can call after RemoveLink the UndoRemoveAction(exChartUndoRedoRemoveLink,1) method to remove the last exChartUndoRedoRemoveLink action from the Undo queue. Use the AddLink method to add links programmatically. Use the Link property of the Items object to access the properties and options of the link. Call the Link( exLinkGroupBars) to group two linked bars. This way they move together when a bar is changed.

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:

Syntax for AddLink event, /NET version, on:

private void AddLink(object sender,string LinkKey)
{
}

Private Sub AddLink(ByVal sender As System.Object,ByVal LinkKey As String) Handles AddLink
End Sub

Syntax for AddLink event, /COM version, on:

private void AddLink(object sender, AxEXG2ANTTLib._IG2anttEvents_AddLinkEvent e)
{
}

void OnAddLink(LPCTSTR LinkKey)
{
}

void __fastcall AddLink(TObject *Sender,BSTR LinkKey)
{
}

procedure AddLink(ASender: TObject; LinkKey : WideString);
begin
end;

procedure AddLink(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_AddLinkEvent);
begin
end;

begin event AddLink(string LinkKey)
end event AddLink

Private Sub AddLink(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_AddLinkEvent) Handles AddLink
End Sub

Private Sub AddLink(ByVal LinkKey As String)
End Sub

Private Sub AddLink(ByVal LinkKey As String)
End Sub

LPARAMETERS LinkKey

PROCEDURE OnAddLink(oG2antt,LinkKey)
RETURN

Syntax for AddLink event, /COM version (others), on:

<SCRIPT EVENT="AddLink(LinkKey)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function AddLink(LinkKey)
End Function
</SCRIPT>

Procedure OnComAddLink String llLinkKey
	Forward Send OnComAddLink llLinkKey
End_Procedure

METHOD OCX_AddLink(LinkKey) CLASS MainDialog
RETURN NIL

void onEvent_AddLink(str _LinkKey)
{
}

function AddLink as v (LinkKey as C)
end function

function nativeObject_AddLink(LinkKey)
return

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

Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.