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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I have a handler for a diagram node click event. How do I determine the identity of the node from the event argument?

 

The node(s) referenced by a diagram node related event such as Diagram.NodeClick, Diagram.NodeMoved etc., will be an instance of the actual object, and you can use the node's type information to ascertain it's identity. If the node has been assigned a uniquely identifiable name at some point during creation, then the Node.Name property can be used as well to access a particular node instance. The following code should give an idea,

C#

// Handler for the Diagram.NodeClick event. Determine the node that was clicked on

private void diagramComponent_NodeClick(object sender, Syncfusion.Windows.Forms.Diagram.NodeMouseEventArgs evtArgs)

{

// Check whether the node clicked is a custom symbol

if(evtArgs.Node is MySymbol)

{

Trace.WriteLine("Node is a custom symbol type");

MySymbol mysmbl = evtArgs.Node as MySymbol;

MessageBox.Show(String.Concat("The custom symbol name is '", mysmbl.Name, "'"));

}

else if(evtArgs.Node is Symbol)

{

Trace.WriteLine("Node is a generic symbol");

Symbol symbl = evtArgs.Node as Symbol;

MessageBox.Show(String.Concat("The symbol name is '", symbl.Name, "'"));

}

else // Node is a non-Symbol node

{

// Ignore if the event is being generated for a Symbol's child node

if((evtArgs.Node.Parent != null) && !(evtArgs.Node.Parent is Symbol))

{

Trace.WriteLine(evtArgs.Node.GetType());

MessageBox.Show(String.Concat("The node name is '", evtArgs.Node.Name, "'"));

}

}

}

VB

' Handler for the Diagram.NodeClick event. Determine the node that was clicked on

Private Sub diagramComponent_NodeClick(ByVal sender As Object, ByVal evtArgs As Syncfusion.Windows.Forms.Diagram.NodeMouseEventArgs)

' Check whether the node clicked is a custom symbol

If TypeOf evtArgs.Node Is MySymbol Then

Trace.WriteLine("Node is a custom symbol type")

Dim mysmbl As MySymbol = evtArgs.Node as MySymbol

MessageBox.Show(String.Concat("The custom symbol name is '", mysmbl.Name, "'"))

Else If TypeOf evtArgs.Node Is Symbol Then

Trace.WriteLine("Node is a generic symbol")

Dim symbl As Symbol = evtArgs.Node as Symbol

MessageBox.Show(String.Concat("The symbol name is '", symbl.Name, "'"))

Else ' Node is a non-Symbol node

' Ignore if the event is being generated for a Symbol's child node

If Not (evtArgs.Node.Parent Is Symbol) Then

Trace.WriteLine(evtArgs.Node.GetType())

MessageBox.Show(String.Concat("The node name is '", evtArgs.Node.Name, "'"))

End If

End If

End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
199 04/30/2011 07/10/2014 WinForms Diagram
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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