Applies to: Nevron Diagram for .NET

How to Subscribe to Diagram Shape Events?

You can fire an event on the creation of a new shape, or when an already created shape is altered/deleted. The NodeInserted and NoderRemoved events of the document event sink service will be fired whenever a node has been inserted or removed from the document regardless of the way in which this was done. You can subscribe for this events with the following code:

[C#]
document.EventSinkService.NodeInserted += new ChildNodeEventHandler(OnNodeInserted);
document.EventSinkService.NodeRemoved += new ChildNodeEventHandler(OnNodeRemoved);
  
private void OnNodeInserted(NChildNodeEventArgs args)
{
    if (args.Child is NShape)
    {
        // do something when a shape is added
    }
}
  
  
private void OnNodeRemoved(NChildNodeEventArgs args)
{
    if (args.Child is NShape)
    {
        // do something when a shape is removed
    }
}

[VB.NET]
AddHandler document.EventSinkService.NodeInserted, AddressOf OnNodeInserted
AddHandler document.EventSinkService.NodeRemoved, AddressOf OnNodeRemoved
   
Private Sub OnNodeInserted(args As NChildNodeEventArgs)
            ' do something when a shape is added
    If TypeOf args.Child Is NShape Then
    End If
End Sub
   
   
Private Sub OnNodeRemoved(args As NChildNodeEventArgs)
            ' do something when a shape is removed
    If TypeOf args.Child Is NShape Then
    End If
End Sub

Article ID: 34, Created On: 10/5/2010, Modified: 5/5/2011