We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I enable the single link between the nodes?

 

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://help.syncfusion.com/support/samples/kb/diagram.windows/diagramsinglelink/CS.zip

Article ID: Published Date: Last Revised Date: Platform: Control:
235 04/30/2011 07/10/2014 WinForms Diagram
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon