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

How to remove connections from a node?

Hi,

When I remove a node, I want to remove all connections (created by PolyLinkLine) connected to one of the ports of my node as well. I remarked that in the EventSink_NodeCollectionChanging(), the information of which connection is linked to my node is already gone...

Thank you for your advice,
Stefan.


3 Replies

FS Fathima Shalini P Syncfusion Team May 22, 2008 11:27 AM UTC

Hi Stefan,

Thank you for your interest in Syncfusion Products.

To delete node with link we need to use EventSink_NodeCollectionChanged event. Please find the following code snippet that illustrates this:


void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
LineConnector line; Node tonode, fromNode;
Node m_node = evtArgs.Element as Node;
if (m_node is Node)
{
if (evtArgs.ChangeType == CollectionExChangeType.Remove)
{
IEnumerator enumnodes = this.myDiagram1.Model.Nodes.GetEnumerator();
NodeCollection links = new NodeCollection();
while (enumnodes.MoveNext())
{
Node node = enumnodes.Current as Node;
//Determine if the node is of type Link
if (node.GetType() == typeof(Syncfusion.Windows.Forms.Diagram.PolyLineConnector))
{
line = node as PolyLineConnector;
tonode = line.ToNode as Node;
fromNode = line.FromNode as Node;
if (tonode == null || fromNode == null)
{
this.myDiagram1.Model.RemoveChild(line);
}
}
}
}
}
}


Please refer the below sample in the following link:

http://websamples.syncfusion.com/samples/Diagram.Windows/46162/main.htm

Please let me know if any concerns.

Regards,
Fathima



TL Truman Lackey July 18, 2008 05:49 PM UTC

I believe there is a problem with this code if there is a symbol with only a connection on one end (I'll call it dangling) or a link line with no connections. Any links/lines with these properties will also be removed. I have tried doing something following the old example here
http://www.syncfusion.com/support/forums/message.aspx?MessageID=20459
but the edges seem to be removed from the node before the event gets fired.

An update on how to remove links coming in and out of node is needed.



J. J.Nagarajan Syncfusion Team July 21, 2008 01:39 PM UTC

Hi Truman ,

We regret for the incovenience caused. I was able to see the issue "Node.Edges returns null when the LineConnector is exist" in 6.3.0.30. I have logged a defect report in this regard. I have forwarded this issue to our developers for more analysis. I will get back to you with more details regarding this issue on or before 23rd July,2008.

Thanks for your patience.

Regards,
Nagaraj


Loader.
Live Chat Icon For mobile
Up arrow icon