|
-
Mar 29th, 2000, 02:56 AM
#1
Thread Starter
Member
I can do the code for a normal click on tree view but what about right click, thanks for any help
-
Mar 29th, 2000, 03:57 AM
#2
What exactly do you mean? If you mean that you want to trap the Node you clicked on, then you can use NodeClick event, which has 1 argument - Node object that represents the node you clicked.
If you mean something different, please rephrase.
-
Mar 29th, 2000, 04:08 AM
#3
Thread Starter
Member
Sorry for the confusion, Yes I want to trap the node on a right click, for example, lets say I have a node that is call desserts, and this node has three child nodes. One of the child nodes is called Chocolate Cake, whe the user right clicks on this child node I want to execute some code. I know how to do the NodeClick(ByVal Node As MSComctlLib.Node), but this is for either left or right click, any way to keep it to right only, thanks again
-
Mar 29th, 2000, 04:20 AM
#4
transcendental analytic
This can be solved by co-operating with another event:
Private Sub tvtree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
tvtree.Tag = Button
End Sub
Private Sub tvtree_NodeClick(ByVal Node As ComctlLib.Node)
Select Case Val(tvtree.Tag)
Case 1
MsgBox "Left click"
Case 2
MsgBox "Right click"
End Select
End Sub
Hope this works!
-
Mar 29th, 2000, 04:25 AM
#5
Node click doesn't care what button you clicked with. What you can do is to use a MouseDown event to check if the user clicked with the right mouse button and then fire your function (or whatever you have there setup)
Code:
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim nodCurrent As Node
If Button = vbRightButton Then
Set nodCurrent = TreeView1.HitTest(x, y)
If Not nodCurrent Is Nothing Then
nodCurrent.Selected = True
MsgBox "You right clicked on " & nodCurrent.Text
End If
End If
End Sub
-
Mar 29th, 2000, 04:28 AM
#6
Thread Starter
Member
-
Mar 29th, 2000, 06:08 AM
#7
Fanatic Member
I think a better way is use a menu on a hidden form (a form that will not be visible when the application is run but will be loaded none-the-less) and then to use the popupmuenu command to popup the menu which is on the hidden form, that way you can set the event code for as many options as you like.
Doc Zaf
{;->
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|