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.
Unfortunately, activation email could not send to your email. Please try again.

AppendChild doesn''t add a node if outside the diagram

Thread ID:





62674 Jun 20,2007 06:15 AM Jun 20,2007 11:55 AM Windows Forms 2
Tags: Diagram
Daniele Sincich
Asked On June 20, 2007 06:15 AM

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):

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");

ControlNode StepNode = new ControlNode(StepBox, new RectangleF(100, (i * 100) + 50, StepBox.Width, StepBox.Height));
StepNode.Name = StepBox.IdFase;
StepNode.EditStyle.AllowSelect = false;

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.

Is this a bug or a "by design" behaviour?

Meera Fathima [Syncfusion]
Replied On June 20, 2007 08:12 AM

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.

this.diagram1.Model.BoundaryConstraintsEnabled = false;

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));

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,

Daniele Sincich
Replied On June 20, 2007 11:55 AM

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.

Thank you again and best regars


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.