Bonjour,
J'aimerai avoir des explications sur le code qui permet de créer un menu contextuel sur clic droit pour un Treeview (voir photo). J'ai trouvé un code qui fonctionne et que je souhaite adapter pour mon application. Le code est issu de la base exemple Northwind.
voici ce que je comprends:
1- sur clic, appel de la fonction suivante pour l'objet Treeview (axProducts)
2 - Ensuite dans le module (alxmdlMenus) il y a :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 Private Sub axProducts_NodeClick(ByVal Node As Object) axProductsNodeClick Node End Sub Private Sub axProductsNodeClick(nSelectedNode As MSComctlLib.Node, Optional fSkipHistory As Boolean) Dim h As New clsHistoryInfo strCurrentNode = nSelectedNode.Key If Not fSkipHistory Then lngHistoryIndex = lngHistoryIndex + 1 If lngHistoryIndex <= colHistory.Count Then colHistory.Item(lngHistoryIndex).strNode = strCurrentNode colHistory.Item(lngHistoryIndex).strNodeText = nSelectedNode.Text Else h.strNode = strCurrentNode h.strNodeText = nSelectedNode.Text colHistory.Add h CommandBars("Treeview").Controls("Forward").Enabled = False End If CommandBars("Treeview").Controls("Back").Enabled = True SetHistoryToolTip End If Me.lblFullPath.Caption = nSelectedNode.FullPath End Sub
3 ... qui appelle les fonctions suivantes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Public Function mnuDelete() Screen.ActiveForm.DeleteRecord End Function Public Function mnuAdd() Screen.ActiveForm.AddBranch End Function
je ne vois pas ou le menu du clic droit est construit avec les chaines de caractères (Add, Delete) ainsi que les images...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Public Sub AddRecord() MsgBox "Code to Add" End Sub Public Sub DeleteRecord() MsgBox "Code to Delete" End Sub
Merci pour votre aide!
Partager