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.

Removing all the nodes on a layer from the model

Thread ID:





70863 Jan 4,2008 03:47 PM Oct 5,2010 07:07 AM Windows Forms 2
Tags: Diagram
Michael Jones
Asked On January 4, 2008 03:47 PM

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 12:09 AM

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 07:07 AM

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.

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.