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 create a connection programmatically?

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

How do I create a connection programmatically?

Typically, symbols and links are connected together using the interactive LinkTool UI tool or the LinkCmd command class. Sometimes it is useful to create connections programmatically. For example, you might be generating a diagram from data in a database or possibly even writing your own custom link tool. You might even create a connection between two symbols directly without having a link in between.

The following code creates a link and connects it to the center ports of two symbols:

[C#]

public Link LinkSymbols(Symbol sym1, Symbol sym2) {     
Link link = new Link(Link.Shapes.Line);    
sym1.Connect(sym1.CenterPort, link.TailPort);     
sym2.Connect(link.HeadPort, sym2.CenterPort);    
 return link; }

[VB.NET]

Public Function LinkSymbols(ByVal sym1 As Symbol, ByVal sym2 As Symbol) As Link    
 Dim link As Link =  New Link(Link.Shapes.Line)    
 sym1.Connect(sym1.CenterPort, link.TailPort)    
 sym2.Connect(link.HeadPort, sym2.CenterPort)     
Return link End Function

 

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

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.