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.
Unfortunately, activation email could not send to your email. Please try again.

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)

 

Syncfusion Inc.

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

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.