The Syncfusion® native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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?
please ignore the switch statement in my example, i chopped my code down and forgot to remove it
ADAdministrator 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.