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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Removing all the nodes on a layer from the model

Thread ID:





70863 Jan 4,2008 08:47 PM UTC Oct 5,2010 11:07 AM UTC WinForms 2
Tags: Diagram
Michael Jones
Asked On January 4, 2008 08:47 PM UTC

How do you remove all the nodes from a layer - deleting the nodes from the diagram.

I tried this, but it has no effect:

for (int i = DiagramCanvas.Model.Layers[myLayerName].Nodes.Count - 1; i > 0; i--)

I have also tried removing directrly from the model using:


Sri Rajan [Syncfusion]
Replied On January 5, 2008 05:09 AM UTC

Hi Michael ,

If your intention is to remove all the nodes from the layer then you can use Model.RemoveChild() method. Please refer to the following code snippet.


foreach (INode node in this.layer1.Nodes)
Node objnode = node as Node;

Please refer the below sample to remove all the node from the diagram.


In this sample you can remove the nodes in the layer by clicking on File-> RemoveNodes menuitem.

Please let me know if you have any questions.


Witold Slirz
Replied On October 5, 2010 11:07 AM UTC

It does not work.
If you use code like

foreach (Node node in _activeDiagram.Model.Layers[0].Nodes)
node.EditStyle.AllowDelete = true;

Exception "collection was modified" occurs after one iteration.

How to delete all nodes from a layer?


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon