How To Create a Connection Programmatically
29 Feb 2016 / 1 minute to read
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 the 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.
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;
}
Public Function LinkSymbols(ByVal sym1 As Syncfusion.Windows.Forms.Diagram.Symbol, ByVal sym2 As Syncfusion.Windows.Forms.Diagram.Symbol) As LinkLabel.Link
Dim link As LinkLabel.Link = New LinkLabel.Link(link.Shapes.Line)
sym1.Connect(sym1.CenterPort, link.TailPort)
sym2.Connect(link.HeadPort, sym2.CenterPort)
Return link
End Function
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page