

| Type | Description | |||
| LinkKey as Variant | A String expression that indicates the key of the link. This value is used to identify the link. | |||
| StartItem as HITEM | A HITEM expression that indicates the handle of the item where the link starts. | |||
| StartBarKey as Variant | A String expression that indicates the key of the bar in the StartItem where the link starts. | |||
| EndItem as HITEM | A HITEM expression that indicates the handle of the item where the link ends. | |||
| EndBarKey as Variant | A String expression that indicates the key of the bar in the EndItem where the link ends. |

The following VB sample adds a link between two bars:
G2antt1.BeginUpdate
With G2antt1.Items
Dim h1 As HITEM
h1 = .AddItem("Item 1")
.AddBar h1, "Task", G2antt1.Chart.FirstVisibleDate + 2, G2antt1.Chart.FirstVisibleDate + 4
Dim h2 As HITEM
h2 = .AddItem("Item 2")
.AddBar h2, "Task", G2antt1.Chart.FirstVisibleDate + 1, G2antt1.Chart.FirstVisibleDate + 2, "A"
.AddLink "Link11", h1, "", h2, "A"
End With
G2antt1.EndUpdate
The following C++ sample adds a link between two bars:
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
m_g2antt.BeginUpdate();
CItems items = m_g2antt.GetItems();
CChart chart = m_g2antt.GetChart();
long h1 = items.AddItem( COleVariant( "Item1" ) );
items.AddBar( h1, COleVariant( "Task" ), COleVariant( V_DATE(&chart.GetFirstVisibleDate()) + 2 ), COleVariant( V_DATE(&chart.GetFirstVisibleDate()) + 4 ), vtMissing, vtMissing );
long h2 = items.AddItem( COleVariant( "Item2" ) );
items.AddBar( h2, COleVariant( "Task" ), COleVariant( V_DATE(&chart.GetFirstVisibleDate()) + 1 ), COleVariant( V_DATE(&chart.GetFirstVisibleDate()) + 2 ), COleVariant("JustAKey"), vtMissing );
items.AddLink( COleVariant( "Link1" ), h1, vtMissing, h2, COleVariant("JustAKey") );
m_g2antt.EndUpdate();The following VB.NET sample adds a link between two bars:
AxG2antt1.BeginUpdate()
Dim d As Date = AxG2antt1.Chart.FirstVisibleDate
With AxG2antt1.Items
Dim h1 As Integer = .AddItem("Item 1")
.AddBar(h1, "Task", d.AddDays(2), d.AddDays(4))
Dim h2 As Integer = .AddItem("Item 2")
.AddBar(h2, "Task", d.AddDays(1), d.AddDays(2), "A")
.AddLink("Link11", h1, "", h2, "A")
End With
AxG2antt1.EndUpdate()The following C# sample adds a link between two bars:
axG2antt1.BeginUpdate();
DateTime d = Convert.ToDateTime(axG2antt1.Chart.FirstVisibleDate);
EXG2ANTTLib.Items spItems = axG2antt1.Items;
int h1 = spItems.AddItem("Item 1");
spItems.AddBar(h1, "Task", d.AddDays(2), d.AddDays(4) , null, null);
int h2 = spItems.AddItem("Item 2");
spItems.AddBar(h2, "Task", d.AddDays(1), d.AddDays(2), "A", null);
spItems.AddLink("Link1", h1, null, h2, "A");
axG2antt1.EndUpdate();The following VFP sample adds a link between two bars:
thisform.G2antt1.BeginUpdate
local d
d = thisform.G2antt1.Chart.FirstVisibleDate
With thisform.G2antt1.Items
local h1
.DefaultItem = .AddItem("Item 1")
h1 = .DefaultItem
.AddBar(0, "Task", thisform.G2antt1.Chart.NextDate(d,4096,2), thisform.G2antt1.Chart.NextDate(d,4096,4))
local h2
.DefaultItem = .AddItem("Item 2")
h2 = .DefaultItem
.AddBar(0, "Task", thisform.G2antt1.Chart.NextDate(d,4096,1), thisform.G2antt1.Chart.NextDate(d,4096,2), "A")
.AddLink("Link11", h1, "", h2, "A")
EndWith
thisform.G2antt1.EndUpdate