The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
PMPandi Murugan A Syncfusion Team June 3, 2011 04:53 AM UTC
Hi Edward,
Thanks for using Syncfusion products.
Here is the code snippet to achieve your requirement. [C#] //Add NodeCollectionChanged event diagram1.Model.EventSink.NodeCollectionChanged += new CollectionExEventHandler(EventSink_NodeCollectionChanged);
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs) { //Check whether the selected node is deleted or not if (evtArgs.ChangeType == CollectionExChangeType.Remove) { if (evtArgs.Elements != null) { foreach (Node node in evtArgs.Elements) DeleteChild(node);//Delete child and inner level child } } }
void DeleteChild(Node parent) { NodeCollection nodes = new NodeCollection(); foreach (ConnectorBase link in parent.EdgesLeaving) { if (link.ToNode != null) { DeleteChild((Node)link.ToNode); nodes.Add((Node)link.ToNode);//Add the child to the collection for deleting } nodes.Add(link);//Add the link from parent to the collection for deleting } foreach (Node node in nodes) { diagram1.Model.RemoveChild(node);//remove the child from model } }
Please try this and let me know if this is helps.
Regards, Pandi Murugan A
EDedJune 5, 2011 04:14 AM UTC
perfect just what I needed thanks for your help
Greetings
Edward Montiel
EDedJune 5, 2011 08:42 PM UTC
Now I have this question, how to have the user can not remove the nodes with the Delete key, is there any way to remove that function
Greetings
Edward Montiel
AAAmsath Ali M Syncfusion Team June 6, 2011 11:52 AM UTC
Hi Edward,
Thanks for the update.
We suggest you to use the below code snippet to restrict the user from deleting the node through ‘Delete’ Key. [C#]:
diagram1.KeyDown += new KeyEventHandler(diagram1_KeyDown);
void diagram1_KeyDown(object sender, KeyEventArgs e) { //Check whether the delete key is pressed or not if (e.KeyCode == Keys.Delete) { e.SuppressKeyPress = true; } }