We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I determine when a new symbol or shape has been added to or removed from the Diagram?

Platform: WinForms |
Control: Diagram |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014


The Diagram.Model.ChildrenChangeComplete event can be used to determine when a new node( symbol,shape or link) has been added or removed from the diagram. The event's Diagram.NodeCollection.EventArgs event argument provides information about the node and the ensuing operation such as addition or removal.

The following code sample updates the label with information on the type of node that is added to or deleted from the Diagram:

[C#] //Listen to the Diagram Model's ChildrenChangeComplete Event. this.diagram1.Model.ChildrenChangeComplete+=new Syncfusion.Windows.Forms.Diagram.NodeCollection.EventHandler(Model_ChildrenChangeComplete);

//ChildrenChangeComplete Event //Update Label2 depending on whether a Shape is added or deleted from the Diagram private void Model_ChildrenChangeComplete(object sender, Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs evtArgs) {  if (evtArgs.ChangeType.ToString() == "Insert")  {     this.label2.ForeColor = Color.Blue;   this.label2.Text = "Last Node Added: " + evtArgs.Node.Name.ToString();  }  else if (evtArgs.ChangeType.ToString() == "Remove")  {     this.label2.ForeColor = Color.Red;   this.label2.Text = "Last Node Removed: " + evtArgs.Node.Name.ToString();  } }

[VB.NET] 'Listen to the Diagram Model's ChildrenChangeComplete Event. Me.diagram1.Model.ChildrenChangeComplete+=New Syncfusion.Windows.Forms.Diagram.NodeCollection.EventHandler(Model_ChildrenChangeComplete)   'ChildrenChangeComplete Event 'Update Label2 depending on whether a Shape is added or deleted from the Diagram Private  Sub Model_ChildrenChangeComplete(ByVal sender As Object, ByVal evtArgs As Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs)  If evtArgs.ChangeType.ToString() = "Insert" Then   Me.label2.ForeColor = Color.Blue   Me.label2.Text = "Last Node Added: " + evtArgs.Node.Name.ToString()  Else If evtArgs.ChangeType.ToString() = "Remove" Then   Me.label2.ForeColor = Color.Red   Me.label2.Text = "Last Node Removed: " + evtArgs.Node.Name.ToString()  End If End Sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon