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

Testing to see if a connection between two nodes exists

Thread ID:





107516 Mar 5,2013 10:46 PM UTC Mar 6,2013 09:42 AM UTC WinForms 1
Tags: Diagram
Wayne Massey
Asked On March 5, 2013 10:46 PM UTC

I am drawing a diagram based on content from a database table. As part of the process, I create several rectangles and then link them together if they are related. In this application, It is valid for their to be multiple links between two of the same rectangles.
Since there is multiple links, I end up creating the same lineconnector between two rectangles multiple times. As I have a label associated with the lineconnector, the label text merges together.
What I would like to do is If I have a Node, test to see if there is already a connection to a second node. If so, update the existing connection. If not, create a new connection.
I am new here but looking through the help docs, I am not sure how to test this. Is this possible?

Amsath Ali M [Syncfusion]
Replied On March 6, 2013 09:42 AM UTC

Hi Wayne,


Thanks for using Syncfusion products.


We suggest you to use the Diagram.Model.EventSink’s ‘ConnectionChanged’ event to check whether the connections have been present the nodes or not. Please refer the below code snippet to achieve your requirement.

Here is the code:


void EventSink_ConnectionsChanged(CollectionExEventArgs evtArgs)


            if (evtArgs.ChangeType == CollectionExChangeType.Insert)


                if (evtArgs.Element is EndPoint)


                    ConnectorBase conn = ((EndPoint)evtArgs.Element).Container as ConnectorBase;

                    if (conn != null)


                        if (conn.FromNode != null && conn.ToNode != null)


                            Node toNode = conn.ToNode as Node;

                            foreach (ConnectorBase nodeConns in conn.ToNode.Edges)


                                if (((nodeConns.FromNode == conn.FromNode && nodeConns.ToNode == conn.ToNode) ||

                                    (nodeConns.FromNode == conn.ToNode && nodeConns.ToNode == conn.FromNode)) && conn != nodeConns)


                                    evtArgs.Cancel = true;                                   











Here is the sample:



Please let us know if you have any queries.



Amsath Ali. M


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the 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