Search
Handling Events

Most events are raised only in response to users actions. If you need to execute the same code after user actions and API calls, move the common code to a method and invoke the method both in the respective event handler and after the API method or property setter call. A notable exception is the *Deleted set of events, which are also raised when items are deleted programmatically, because in some circumstances deleting an item could delete other items related to it.

When a user starts drawing a new item with the mouse, the control raises an initialization event to let you set the appearance properties of the item. That is, for a node, the control raises InitializeNode.

While the user is holding down the mouse button and drawing, a validation event is raised to let you cancel the item creation (for example, NodeCreating). If the action is not cancelled, a creation event is raised to let your application know about the new item (for example, NodeCreated). There are events raised when users modify items, for example, NodeModifying and NodeModified. Call the CancelDrag method to cancel the item modification or creation from the *Modifying or *Creating events raised for nodes or links.

When a user presses the DEL key, there is a validation event raised to let you confirm deleting an item  (for example, NodeDeleting), and if not cancelled, there is an item-deleted event raised (for example, NodeDeleted).

There are many other events related to various activities a user could carry out on the diagram. The full set of events can be found here:
Diagram Events