event AllowLink (StartItem as HITEM, StartBarKey as Variant, EndItem as HITEM, EndBarKey as Variant, LinkKey as Variant, Cancel as Boolean)
Notifies at runtime when a link between two bars is possible.

 TypeDescription 
   StartItem as HITEM A Long expression that specifies the handle of the item that hosts the bar where the link starts.  
   StartBarKey as Variant A VARIANT expression that specifies the key of the bar where the link starts.  
   EndItem as HITEM A Long expression that specifies the handle of the item that hosts the bar where the link ends.  
   EndBarKey as Variant A VARIANT expression that specifies the key of the bar where the link ends.  
   LinkKey as Variant A String expression that specifies the next available key for the link. Use the LinkKey parameter to change the default key for the newly added link at runtime.  
   Cancel as Boolean A Boolean expression that specifies whether the operation can continue. By default, the Cancel parameter is False. If The Cancel parameter is True, the specified two bars can not be linked, so the link operation is cancelled.  
The AllowLink event occurs when the user links two bars. You can disable or enable linking two bars using the AllowLink event. For instance, you can call Cancel parameter on True, anytime you need to cancel linking two specified bars. 

At runtime, you can control linking two bars using one of the followings:

Syntax for AllowLink event, /NET version, on:

private void AllowLink(object sender,int StartItem,object StartBarKey,int EndItem,object EndBarKey,ref object LinkKey,ref bool Cancel)
{
}

Private Sub AllowLink(ByVal sender As System.Object,ByVal StartItem As Integer,ByVal StartBarKey As Object,ByVal EndItem As Integer,ByVal EndBarKey As Object,ByRef LinkKey As Object,ByRef Cancel As Boolean) Handles AllowLink
End Sub

Syntax for AllowLink event, /COM version, on:

private void AllowLink(object sender, AxEXG2ANTTLib._IG2anttEvents_AllowLinkEvent e)
{
}

void OnAllowLink(long StartItem,VARIANT StartBarKey,long EndItem,VARIANT EndBarKey,VARIANT FAR* LinkKey,BOOL FAR* Cancel)
{
}

void __fastcall AllowLink(TObject *Sender,Exg2anttlib_tlb::HITEM StartItem,Variant StartBarKey,Exg2anttlib_tlb::HITEM EndItem,Variant EndBarKey,Variant * LinkKey,VARIANT_BOOL * Cancel)
{
}

procedure AllowLink(ASender: TObject; StartItem : HITEM;StartBarKey : OleVariant;EndItem : HITEM;EndBarKey : OleVariant;var LinkKey : OleVariant;var Cancel : WordBool);
begin
end;

procedure AllowLink(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_AllowLinkEvent);
begin
end;

begin event AllowLink(long StartItem,any StartBarKey,long EndItem,any EndBarKey,any LinkKey,boolean Cancel)
end event AllowLink

Private Sub AllowLink(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_AllowLinkEvent) Handles AllowLink
End Sub

Private Sub AllowLink(ByVal StartItem As EXG2ANTTLibCtl.HITEM,ByVal StartBarKey As Variant,ByVal EndItem As EXG2ANTTLibCtl.HITEM,ByVal EndBarKey As Variant,LinkKey As Variant,Cancel As Boolean)
End Sub

Private Sub AllowLink(ByVal StartItem As Long,ByVal StartBarKey As Variant,ByVal EndItem As Long,ByVal EndBarKey As Variant,LinkKey As Variant,Cancel As Boolean)
End Sub

LPARAMETERS StartItem,StartBarKey,EndItem,EndBarKey,LinkKey,Cancel

PROCEDURE OnAllowLink(oG2antt,StartItem,StartBarKey,EndItem,EndBarKey,LinkKey,Cancel)
RETURN

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

<SCRIPT EVENT="AllowLink(StartItem,StartBarKey,EndItem,EndBarKey,LinkKey,Cancel)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function AllowLink(StartItem,StartBarKey,EndItem,EndBarKey,LinkKey,Cancel)
End Function
</SCRIPT>

Procedure OnComAllowLink HITEM llStartItem Variant llStartBarKey HITEM llEndItem Variant llEndBarKey Variant llLinkKey Boolean llCancel
	Forward Send OnComAllowLink llStartItem llStartBarKey llEndItem llEndBarKey llLinkKey llCancel
End_Procedure

METHOD OCX_AllowLink(StartItem,StartBarKey,EndItem,EndBarKey,LinkKey,Cancel) CLASS MainDialog
RETURN NIL

void onEvent_AllowLink(int _StartItem,COMVariant _StartBarKey,int _EndItem,COMVariant _EndBarKey,COMVariant /*variant*/ _LinkKey,COMVariant /*bool*/ _Cancel)
{
}

function AllowLink as v (StartItem as OLE::Exontrol.G2antt.1::HITEM,StartBarKey as A,EndItem as OLE::Exontrol.G2antt.1::HITEM,EndBarKey as A,LinkKey as A,Cancel as L)
end function

function nativeObject_AllowLink(StartItem,StartBarKey,EndItem,EndBarKey,LinkKey,Cancel)
return

The following VB sample disable linking bars to any "Summary" bars:

Private Sub G2antt1_AllowLink(ByVal StartItem As EXG2ANTTLibCtl.HITEM, ByVal StartBarKey As Variant, ByVal EndItem As EXG2ANTTLibCtl.HITEM, ByVal EndBarKey As Variant, LinkKey As Variant, Cancel As Boolean)
    With G2antt1.Items
        If (.ItemBar(StartItem, StartBarKey, exBarName) = "Summary") Then
            Cancel = True
        Else
            If (.ItemBar(EndItem, EndBarKey, exBarName) = "Summary") Then
                Cancel = True
            End If
        End If
    End With
End Sub

Use the AddLink method  to create a link between two bars. Use the Link property to access properties of a specified link. The Link(exLinksCount) property retrieves the number of links within the chart.


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