Articles in this section

How to cancel a diagram event?

The following events under diagram.model.eventsink has an option to cancel.

List of cancellable events

NodeCollectionChanged

The NodeCollectionChanged event is raised when the node collection contained in the model is changed (added/removed).

NodeCollectionChanging

The NodeCollectionChanging event is raised while modifying the model’s node collection.

ConnectionsChanged

This ConnectionsChanged event is raised when the connections between the nodes are modified.

ConnectionsChanging

The ConnectionsChanging event is raised while modifying connections between the nodes.

LabelsChanged

The LabelsChanged event is raised when labels are added.

PropertyChanging

The PropertyChanging event is raised while modifying the model’s property.

FlipChanging

The FlipChanging event is raised while the node is inverted using Flip property.

PinOffsetChanging

The PinOffsetChanging event is raised while modifying the offset of the pinpoint.

PinPointChanging

The PinPointChanging event is raised while changing the node’s pinpoint.

PortsChanged

The PortsChanged event is raised when the ports are added or changed.

RotationChanging

The RotationChanging event is raised when the node is rotating.

SizeChanging

The SizeChanging event is raised when the size of the node or connector is modified.

VertexChanging

The VertexChanging event is raised when the vertex of the node is changed.

ZorderChanging

The ZorderChanging event is raised when the Z-order of the node is changed. When the node order is changed from front-to-back or from back-to-front, the ZorderChanging event is raised.

The following code example is used to cancel the events.

C#

diagram1.Model.EventSink.NodeCollectionChanged += EventSink_NodeCollectionChanged;
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
    if (evtArgs.ChangeType == CollectionExChangeType.Remove)
    // Events can be canceled by setting the cancel property to true
        evtArgs.Cancel = true;
}

VB

Private diagram1.Model.EventSink.NodeCollectionChanged += AddressOf EventSink_NodeCollectionChanged
Private Sub EventSink_NodeCollectionChanged(ByVal evtArgs As CollectionExEventArgs)
    If evtArgs.ChangeType = CollectionExChangeType.Remove Then
    ' Events can be canceled by setting the cancel property to true
        evtArgs.Cancel = True
    End If
End Sub

 


Conclusion

I hope you enjoyed learning about how to cancel a diagram event.

You can refer to our WinForms Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our  WinForms Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusio, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied