How do I enable the single link between the nodes?
(Views :1050)

We can eliminate creating two links for the same two symbols by checking the link nodes FromNode, ToNode properties. While creating lines we have to check the end points, if its end points is already exists with the symbols then we have to remove the link. While creating links we can get the link endpoints using ConnectionsChanged event.

C#
//Adding ConnectionChanged event
((DocumentEventSink)model1.EventSink).ConnectionsChanged += new CollectionExEventHandler(MainForm_ConnectionsChanged);
 //Event
void MainForm_ConnectionsChanged(CollectionExEventArgs evtArgs)
{
if (evtArgs.ChangeType == CollectionExChangeType.Insert)
{
foreach (Node n1 in this.diagram1.Model.Nodes)
{
Line tl = n1 as Line;
if (n1 is Line)
{
Line lc1 = n1 as Line;
foreach (Node n in this.diagram1.Model.Nodes)
{
if (n is Line && n != n1)
{
Line lc = n as Line;
if (((lc1.FromNode == lc.FromNode) && (lc1.ToNode == lc.ToNode)) || ((lc1.ToNode == lc.FromNode) && (lc1.FromNode == lc.ToNode)))
{
this.diagram1.Model.RemoveChild(lc1);
MessageBox.Show("Aleardy link has created for the Symbols");
}
}
}
}
}
}
}
VB
''Adding ConnectionChanged event
AddHandler (CType(model1.EventSink, DocumentEventSink)).ConnectionsChanged, AddressOf MainForm_ConnectionsChanged
 ''Event
void MainForm_ConnectionsChanged(CollectionExEventArgs evtArgs)
If evtArgs.ChangeType = CollectionExChangeType.Insert Then
For Each n1 As Node In Me.diagram1.Model.Nodes
Dim tl As Line = TryCast(n1, Line)
If TypeOf n1 Is Line Then
Dim lc1 As Line = TryCast(n1, Line)
For Each n As Node In Me.diagram1.Model.Nodes
If TypeOf n Is Line AndAlso Not n Is n1 Then
Dim lc As Line = TryCast(n, Line)
If ((lc1.FromNode = lc.FromNode) AndAlso (lc1.ToNode = lc.ToNode)) OrElse ((lc1.ToNode = lc.FromNode) AndAlso (lc1.FromNode = lc.ToNode)) Then
Me.diagram1.Model.RemoveChild(lc1)
MessageBox.Show("Aleardy link has created for the Symbols")
End If
End If
Next n
End If
Next n1
End If

Please refer the sample in the below link which illustrates the above:

http://websamples.syncfusion.com/samples/kb/diagram.windows/diagramsinglelink/main.htm
::adCenter::