TreeView prevHoveredNode

40 views Asked by At

How do I use prevHoveredNode property handling event of TreeView?

Event is fired when I click on a node of a TreeView (TSTViewAnalisi)

In output window I read the correct value but when I compile a project, VS2019 marks one error of non existing property.

Private Sub TSTViewAnalisi_MouseUp(sender As Object, e As MouseEventArgs) Handles TSTViewAnalisi.MouseUp 
    Dim a As String = sender.SelectedNode.prevHoveredNode.Text   
1

There are 1 answers

0
djv On

The basic EventHandler Delegate passes you an Object as the first parameter. Object does not have a definition of SelectedNode. But this is expected and common, and you just need to cast the sender to the appropriate type,

Dim s = DirectCast(sender, TreeView)
Dim a = s.SelectedNode.prevHoveredNode.Text

or you could directly access the control

Dim a = TSTViewAnalisi.SelectedNode.prevHoveredNode.Text