Treeview clic droit

Résolu/Fermé
JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023 - Modifié le 10 mai 2021 à 20:24
JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023 - 12 mai 2021 à 20:31
Bonjour,en travaillant avec un treeview j'ai remarque qu'il m'etait impossible de faire clic droit sur un node(noeud) pour que celui-ci puisse apparaitre dans un msgbox montrant le nom du node.
exemple:
Option Explicit
Public Const Treeviewl_project As String = "Treeview demo"

Public Enum emouse
leftclick = 1
rightclick = 2
End Enum


Private Sub TreeView1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
If Button = emouse.rightclick Then
'MsgBox "You rightclicked"
Dim nodX As Node

Set nodX = TreeView1.HitTest(x, y)
If nodX Is Nothing Then
'user clicked empty space
MsgBox "Empty space"
'Call RightClickEmptySpace
Else
'user clicked a node
MsgBox nodX.Text
End If
End If
End Sub



mon probleme se trouve au niveau <MsgBox nodX.Text> cela ne fait rien quand clic sur un node.

1 réponse

JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023
Modifié le 12 mai 2021 à 20:57
j'ai trouve la solutionl alors pour ceux qui auraient a rencontrer le meme probleme que moi,voici la solution:
Private Sub TreeView1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
If Button = emouse.rightclick Then
'MsgBox "You rightclicked"
Dim nodX As Node

Set nodX = TreeView1.HitTest(x*15, y*15)
If nodX Is Nothing Then
'user clicked empty space
MsgBox "Empty space"
'Call RightClickEmptySpace
Else
'user clicked a node
MsgBox nodX.Text
End If
End If
End Sub
0