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

LineConnector Does Not Display

Hi
I'm using syncfusion winforms version : 20.4.0.38

when I'm trying to add a new LineConnector Object on diagram programmatically Id Does Not Appear On diagram But Its Added to Members of Diagram

I Checked this by put a breakpoint and watch this => diagram.Model.Nodes.Members;


I using this snip code to add a Connector between 2 Shape Nodes:

{

        var newConnection = new LineConnector(previousNode.PinPoint, laterNode.PinPoint);

        newConnection.EnableCentralPort = true;

        newConnection.Visible = true;

        newConnection.LineStyle.LineColor = Color.Gold;

        laterNode.CentralPort.TryConnect(newConnection.HeadEndPoint);

        previousNode.CentralPort.TryConnect(newConnection.TailEndPoint);

        diagram.Model.AppendChild(newConnection);

}


Thanks


9 Replies 1 reply marked as answer

DT Deepa Thiruppathy Syncfusion Team January 24, 2023 01:36 PM UTC

Hi Mohammad,


Reported issue: Id does not appear on diagram for a line connector.


Diagram objects such as node, connector has no ID property. They have a Name property to unique identification. By default, value for the Name property will be generated based on element’s type and count. You can set your desired value for that Name property of each diagram elements. This will not be displayed at the diagram page. To show any text on the connector you can add a Label to the diagram elements.


Code snippet:

//Adding label to the line connector.

Syncfusion.Windows.Forms.Diagram.Label label = new Syncfusion.Windows.Forms.Diagram.Label(newConnection, "Line");

label.UpdatePosition = true;

label.FontStyle.Family = "Segoe UI";

label.FontColorStyle.Color = Color.Black;

label.FontStyle.Size = 9;

newConnection.Labels.Add(label);


If we misunderstood your requirement, then please share more details about your requirement.



MO mohammad replied to Deepa Thiruppathy January 25, 2023 09:27 AM UTC

Hi Deepa
I'm Sorry this was typo on my question :)

I mean the LineConnnector Itself does not appear on diagram !!!
But Its added to members of diagram !


in first image :
After deleting Node Number 1  => Node 2 and 3 will be deleted too (Correct)
then I want to Connect Nodes 4 and 5 to each Other

first.JPG

I create a lineConnector programmatically for this

this new Connector added to diagram members but Not Display like image 2 attached


second.JPG



MO mohammad January 29, 2023 07:36 AM UTC

THERE IS AN UPDATE ::

I've Noticed That Node Collection Changed Event Called one more time after NewConnection Node Added to diagram !!!
with these details :
evtArgs.Node.FullName = NewConnection;
evtArgs.Node.ChangeType = Remove;

which means NewConnection Node That I've Added is deleting Automatically !!!!
I can not figure out Why its happening!!!




DT Deepa Thiruppathy Syncfusion Team January 30, 2023 02:00 PM UTC

Hi Mohammad,


Reported issue: Newly added line connector is not added to diagram view


We have created a sample as you explained. We have also removed edges entering and leaving node1 using the NodeCollectionChangingEvent when the event arguments return a ChangeType of 'remove'. We have also created a new connection to connect connector 4 and node 5. We can see that the newly added connection exists in both the diagram.Model.Nodes.Members and view. It was not deleted again.


Can you share the code snippets that you are using in the NodeCollectionChangingEvent to delete edges entering and leaving, as well as the new connection, or modify the sample to reproduce the issue?


Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NewConnection400676649



MO mohammad replied to Deepa Thiruppathy February 1, 2023 11:13 AM UTC

Hi Deepa
(Im using vs 2022 and .Net 6)
Thanks for Answer BUT it did not Change Any Thing
The Problem is Still There
I used EdgeEntering And EdgeLeaving
After AppendChild(NewConnection) and Compelete the NodeCollectionChanging
I get another Call for this event that shows NewConnection Node Removed!!!!(I'm Soo Confused)

Heres My Code to Remove a None Connector Node!!!
And => There is No RemoveChild anywhere else in my entire code
{

Node? preNode = null;

Node nextNode = null;

     if (nodeChanged.EdgesEntering != null)

{

foreach (var connector in nodeChanged.EdgesEntering)

{

var preCon = connector as LineConnector;

preNode = preCon.FromNode as Node;

diagram.Model.RemoveChild(preCon);

}

foreach (var connector in nodeChanged.EdgesLeaving)

{

var nextCon = connector as LineConnector;

nextNode = nextCon.ToNode as Node;

diagram.Model.RemoveChild(nextCon);

}

}

var newConnection = new LineConnector(preNode.PinPoint, nextNode.PinPoint);

newConnection.EnableCentralPort = true;

newConnection.Visible = true;

newConnection.LineStyle.LineColor = Color.Gold;

preNode.CentralPort.TryConnect(newConnection.HeadEndPoint);

nextNode.CentralPort.TryConnect(newConnection.TailEndPoint);

diagram.Model.AppendChild(newConnection);

}



MO mohammad replied to Deepa Thiruppathy February 5, 2023 07:02 AM UTC

Hi deepa
here's my code attached
the problem is in NodeCollectionChanging Event Remove Section 

that After Add a newConnection 
I get another Call for this event that show NewConnection Deleting


Attachment: SyncFusion_Diagraming_Test_a40a303.rar


PP Prakash Perumal Syncfusion Team February 8, 2023 08:33 AM UTC

Hi Mohammad,


Could you please replace the code for generating a new connector with the code given below?

var newConnection = new LineConnector(preNode.PinPoint, nextNode.PinPoint);

newConnection.Name = "NewLineConnector";

newConnection.EnableCentralPort = true;

newConnection.Visible = true;

newConnection.LineStyle.LineColor = Color.Gold;

nextNode.CentralPort.TryConnect(newConnection.HeadEndPoint);

preNode.CentralPort.TryConnect(newConnection.TailEndPoint);

diagram.Model.AppendChild(newConnection);

diagram.Controller.SelectionList.Remove(newConnection);

If the issue persists after replacing the code, please revert us.


Regards,

Prakash


Marked as answer

MO mohammad replied to Prakash Perumal February 13, 2023 11:38 AM UTC

Hi Prakash
Thanks 
That Do the Job

could you explain what's happening after adding the last line of the code?

( diagram.Controller.SelectionList.Remove(newConnection);)


I'm very thankful



PP Prakash Perumal Syncfusion Team February 16, 2023 10:14 AM UTC

Hi Mohammad,


Whenever a new node or connector is added to the diagram, it will be in the selected state. In this case, we are adding a new LineConnector during an ongoing delete process, where the elements in the selection list are removed from the diagram iteratively. As a result, the new connector is also being removed from the diagram. To prevent this, we are removing the new connector from the SelectionList.


I hope this clarifies the purpose of the code.


Regards,

Prakash


Loader.
Live Chat Icon For mobile
Up arrow icon