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. Image for the cookie policy date
close icon

Connecting Diagram to Events

Can I get some samples (in vb) of connecting object in the diagram to events.

What I want to be able to do is take a specific Object on the Diagram and detecting when the mouse is over it or the user clicks the object.

The idea is to use the "diagram" as a connection to a database to pull out real world data points about the object represented on the screen.

I'm not talking about the properties of the object. I want to have my users click on an object and display info from my database about the object. Or said another way I want to be able to pull details about what the object represents in the real world.

Make sense????

Dan

1 Reply

J. J.Nagarajan Syncfusion Team July 27, 2007 06:01 PM UTC

Hi Dan,

If you want to fire a event when you select the node then you have write your own delegate. Please refer to the following code snippet

Public Delegate Sub NodeSelection(ByVal sender As Object, ByVal evtargs As CollectionExEventArgs)
Public Event evtnodeselection As NodeSelection

AddHandler evtnodeselection, AddressOf MainForm_evtnodeselection

'Fire the NodeSelection Event
Private Sub MainForm_evtnodeselection(ByVal sender As Object, ByVal evtargs As CollectionExEventArgs)
Dim node As Node = CType(IIf(TypeOf evtargs.Element Is Node, evtargs.Element, Nothing), Node)
Console.WriteLine(node.Name)
End Sub

'NodeCollectionChanged event
Private Sub EventSink_NodeCollectionChanged(ByVal evtArgs As CollectionExEventArgs)
Dim controller As DiagramController = Me.diagram1.Controller
Dim node As Node = CType(IIf(TypeOf evtArgs.Element Is Node, evtArgs.Element, Nothing), Node)
If Not node Is Nothing Then
If node Is controller.SelectionList.First Then
'Fire the NodeSelection event
RaiseEvent evtnodeselection(Me, evtArgs)
End If
End If
End Sub

I have attached the sample that demonstrates this completely.

http://websamples.syncfusion.com/samples/Diagram.Windows/F65575/main.htm

Please refer to the sample and let me know if you have any questions.

Thanks,
Nagaraj

Loader.
Live Chat Icon For mobile
Up arrow icon