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 to draw links between two node or how to connect two nodes with a line connector programmatically?

Platform: WinForms |
Control: Diagram |
Published Date: April 30, 2011 |
Last Revised Date: June 3, 2019

How to draw links between two node or how to connect two nodes with a line connector programmatically?

The following code is demonstrated in Symbol Design\Dynamic Symbol class.

C#

NodeCollection symbols = new NodeCollection();
 // Add nodes of custom symbol type.
MySymbol symbol1 = new MySymbol();
symbol1.PinPoint = new PointF(10 + symbol1.PinPointOffset.Width, 10 + symbol1.PinPointOffset.Height);
symbol1.EnableCentralPort = true;
symbols.Add(symbol1);
 MySymbol symbol2 = new MySymbol();
symbol2.PinPoint = new PointF(200, 200);
symbol2.EnableCentralPort = true;
symbols.Add(symbol2);
 int position = 0;
 // Draw the Lineconnector and add it to the nodes collection.
LineConnector line = new LineConnector(symbol1.PinPoint, symbol2.PinPoint);
symbols.Add(line);
 // Add the nodes collection that has nodes and the connectors to the diagram model.
this.diagram1.Model.AppendChildren(symbols, out position);
 // Make connection between the two nodes and the line connector through its end point.
symbol1.CentralPort.TryConnect(line.HeadEndPoint);
symbol2.CentralPort.TryConnect(line.TailEndPoint);
 

 

VB

Private symbols As NodeCollection = New NodeCollection()
 '' Add nodes of custom symbol type.
Private symbol1 As MySymbol = New MySymbol()
symbol1.PinPoint = New PointF(10 + symbol1.PinPointOffset.Width, 10 + symbol1.PinPointOffset.Height)
symbol1.EnableCentralPort = True
symbols.Add(symbol1)
 Private symbol2 As MySymbol = New MySymbol()
symbol2.PinPoint = New PointF(200, 200)
symbol2.EnableCentralPort = True
symbols.Add(symbol2)
 Private position As Integer = 0
 '' Draw the Lineconnector and add it to the nodes collection.
Private line As LineConnector = New LineConnector(symbol1.PinPoint, symbol2.PinPoint)
symbols.Add(line)
 '' Add the nodes collection that has nodes and the connectors to the diagram model.
Me.diagram1.Model.AppendChildren(symbols, position)
 '' Make connection between the two nodes and the line connector through its end point.
symbol1.CentralPort.TryConnect(line.HeadEndPoint)
symbol2.CentralPort.TryConnect(line.TailEndPoint)
 

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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