[RESOLVED] TreeView right mice button click
When you right click your mice over some Node in a TreeView it gets selected for a brief moment (talking about the region that is not the "Text" of that Node - if you have FullRowSelect at True of course).
I know there is a way i can keep it selected, just don't know how :duck:
Thanks!
-gav
Re: TreeView right mice button click
Do you have "HideSelection" set to False?
Re: TreeView right mice button click
On a right mouse click, the DropHighlight property is set to the node that was clicked upon but only within the MouseUp event. It does not matter if FullRowSelect is true or false.
Code:
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
If Not TreeView1.DropHighlight Is Nothing Then
TreeView1.DropHighlight.Selected = True
End If
End If
End Sub
If you need to find the clicked upon node in the MouseDown event use this code
Code:
Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngIdx As Long
Dim oNode As Node
If Button = vbRightButton Then
Set oNode = TreeView1.HitTest(x, y)
If oNode Is Nothing Then
'click did not occur directly on a node's text
'check if it may have occurred elsewhere along the node's row
For lngIdx = 1 To TreeView1.Width Step 100
Set oNode = TreeView1.HitTest(lngIdx, y)
If Not oNode Is Nothing Then
oNode.Selected = True
Exit For
End If
Next
Else
oNode.Selected = True
End If
End If
End Sub
Re: TreeView right mice button click
Quote:
Originally Posted by RobDog888
Do you have "HideSelection" set to False?
It doesn't matter. HideSelection only hides (if set to True) the "selection" of the selected item when TV looses focus. That's not my problem :)
Re: TreeView right mice button click
@brucevde: u can't miss, can u :D thanks ;)
Re: [RESOLVED] TreeView right mice button click
You win some, you lose some. :)