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. Image for the cookie policy date
close icon

Programmatically adding links

Hi, I am trying to programmatically add a bunch of symbols to the diagram and link them, based on data from a dataset. I have used the following code to create the symbols. foreach(System.Data.DataRow row1 in dtInstance.Rows) { switch (row1[0].ToString().ToLower()) { rect[intRow] = new Syncfusion.Windows.Forms.Diagram.Rectangle(intOffsetX,intOffsetY,80,30); sym[intRow] = new Symbol(); sym[intRow].Name = "Node_" + intRow.toString(); sym[intRow].AppendChild(rect[intRow]); diagramComponent.Model.AppendChild(sym[intRow]); //Add Label Syncfusion.Windows.Forms.Diagram.Label lbl = sym[intRow].AddLabel("Some text", BoxPosition.Center); intRow++; } } this adds the symols just fine, and I know that the following code block, when referencing the appropriate symbols will draw the links that I am after. Link link = new Link(Link.Shapes.Line); sym[1].Connect(sym[1].CenterPort, link.TailPort); sym[2].Connect(link.HeadPort, sym[2].CenterPort); diagramComponent.Model.AppendChild(link); my problem is that when I come to draw the links, I do not know what sym[x] to reference, I only have the names given to the .Name property of the symbols. Can I programmatically refer to the symbol names, instead of their object name?

2 Replies

RI Rich June 23, 2004 01:59 AM UTC

please ignore the switch statement in my example, i chopped my code down and forgot to remove it


AD Administrator Syncfusion Team June 25, 2004 11:58 AM UTC

Hi Richard, The Diagram''s model has a Model.Nodes property that returns a INodeCollection of all nodes that are present in the model. You can use this property to implement a utility function in your application that iterates the node collection, determines whether a particular node is a Symbol type and if so retrieves it after comparing it with the provided name. Prakash Syncfusion, Inc.

Loader.
Live Chat Icon For mobile
Up arrow icon