This is a migrated thread and some comments may be shown as answers.

Connect two items programmatically

2 Answers 56 Views
Diagram, DiagramRibbonBar, DiagramToolBox
This is a migrated thread and some comments may be shown as answers.
Sina
Top achievements
Rank 1
Sina asked on 21 Jun 2017, 05:42 AM

Hi,

I want to connect two item on the diagram programmatically. I am not sure that the procedure is correct or not?

1) set a  ID (name)

2) search diagram.Shap array and find two ID

3) make connection with source and target index based on ID <name> found in step 2

Thank you.

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Jun 2017, 08:31 AM
Hello Sina,

Thank you for writing.

You can find shapes in your diagram based on their name, then you can create a connection between them using the approach suggested here: http://docs.telerik.com/devtools/winforms/diagram/diagram-items/connections/connection-types

var source = this.radDiagram1.Shapes.Where(s => s.Name == "Source").FirstOrDefault();
var target = this.radDiagram1.Shapes.Where(s => s.Name == "Target").FirstOrDefault();
 
RadDiagramConnection polylineConnection = new RadDiagramConnection() { Name = "connection1" };
 
polylineConnection.Source = source;
polylineConnection.Target = target;
polylineConnection.ConnectionType = Telerik.Windows.Diagrams.Core.ConnectionType.Polyline;
radDiagram1.AddShape(polylineConnection);

I hope this helps. Should you have further questions do not hesitate to write back.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Sina
Top achievements
Rank 1
answered on 25 Jun 2017, 02:57 AM

Dear Hristo,

It works! 

Thank you. 

Tags
Diagram, DiagramRibbonBar, DiagramToolBox
Asked by
Sina
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Sina
Top achievements
Rank 1
Share this question
or