Search code examples
vb.nettreeviewtooltip

How to create a tooltip on the nodes of a treeview in vb.net?


I cannot display tooltips on the nodes of a treeview! I have a ToolTip1 control and I passed the ShowNodeToolTips property to True on the TreeView. I only want to display the text of the node that the mouse hovers in tooltips. Unfortunately, I have no code start except this one:

Dim Noeud As TreeNode = Me.TreeView1.GetNodeAt(e.X, e.Y)
If Not (Noeud Is Nothing) Then
...
End if

Claude.

PS : I just gave it a try and it seems to me that as soon as the text of the Node exceeds the width of the TreeView, the tooltip appears!


Solution

  • Treeviews don't require a ToolTip control to have tips.

    In the treeview control

        TreeView1.ShowNodeToolTips = True
    

    then in the nodes of the treeview set the

        .ToolTipText 
    

    to what you want to display.