The code you have used to disable shape deleting with the “Delete” key is not correct. There are 2 better ways to achieve this functionality in Nevron Diagram For .NET.
1. The first way (which is the one I recommend) is to set “Delete” protection to all shapes you want to forbid removing of. The following code demonstrates how to set “Delete” protection to all shapes in the active layer of a drawing document:
NNodeList shapes = document.ActiveLayer.Descendants(NFilters.TypeNShape, -1);
for (int i = 0, count = shapes.Count; i < count; i++)
{
NShape shape = (NShape)shapes[i];
NAbilities protection = shape.Protection;
protection.Delete = true;
shape.Protection = protection;
}
Note that setting a “Delete” protection will show a message to the user when he tries to delete a shape with the “Delete” keyboard key. If you don’t want this message to be shown, you can set the ShowMessage property of the drawing view to false:
view.ShowMessages = false;
2. The second way to disable shape from deleting is to use the NodeRemoving event of the drawing document’s event sink service and set the Cancel property of the event arguments to true.
document.EventSinkService.NodeRemoving += OnNodeRemoving;
private void OnNodeRemoving(NChildNodeCancelEventArgs args)
{
args.Cancel = true;
}
In general all the “...ing” events of the event sink service are cancellable, so you can cancel them in this way when necessary.
Best Regards,
Nevron Support Team