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.
I programmatically (C# VS2005) add a bunch of nodes in a diagram for subsequent arrangement with a TreeLayout. First I place the nodes in the diagram, then add the lines connecting the nodes, and when there are a lot of nodes I got the "object not set" error adding a line. After some debugging, I discovered that adding a node with coordinates that would place it outside the diagram doesn't throw an exception neither create the node, leading to the following error when adding the line.
This is the code I used for creating the nodes (from a custom control named dswBoxStep):
diaFlowChart.Model.Nodes.Clear(); int i = 0; foreach (DataRow Srow in dtSteps.Rows) { dswBoxStep StepBox = new dswBoxStep(); StepBox.DBConnectionString = _DBConnectionString; StepBox.IdStep = Srow["UIDCommFase"].ToString(); StepBox.Name = "Step_" + i.ToString("000"); StepBox.ShowFase();
ControlNode StepNode = new ControlNode(StepBox, new RectangleF(100, (i * 100) + 50, StepBox.Width, StepBox.Height)); StepNode.Name = StepBox.IdFase; StepNode.EditStyle.AllowSelect = false; diaFlowChart.Model.AppendChild(StepNode); i++; }
The AppendChild method doesn't create the node if the position of the ControlNode is outside, but it doesn't throw any exception. I solved the problem positioning all the nodes in the same position, since the TreeLayout arrangement repositions them in an appropriate manner.
MFMeera Fathima Syncfusion Team June 20, 2007 12:12 PM UTC
Hello Daniele Sincich,
Thank you for the code snippet. And regarding your query, if your intension is to place the nodes outside of the diagram bounds, you need to set the Diagram.Model.BoundaryConstraintsEnabled property to false value before appending the nodes into the diagram.
I have tested this case by adding the below sample code snippet in the ControlsGalore sample's Form_Load() method and is working fine for me. I have also given the sample code snippet that I have used for your reference.
TextBox txtBox = new TextBox(); txtBox.Multiline = true; txtBox.Text = "This is text in a TextNode";
ControlNode ctrlnode = new ControlNode(txtBox, new RectangleF(100, 1130, 140, 50)); this.diagram1.Model.AppendChild(ctrlnode);
Please try setting the Diagram.Model.BoundaryConstraintsEnabled property to false value and let me know if you still finds any issues with this.
Thanks and Regards, Meera.
DSDaniele Sincich June 20, 2007 03:55 PM UTC
With "Diagram.Model.BoundaryContraintsEnabled = False" the code works well even if the nodes are outside diagram area: added to my code for extreme safety. Many thanks !!!
BTW, in my first post I wrote that the error didn't occur placing all nodes in the same position. It's wrong, in this case only the first node is displayed and all the subsequent nodes in the same Top & Left position were not added to the diagram.