[RESOLVED] Treeview Highlight Problem.
I expect this is probably a simple answer, but I can't find it. ;)
When you left click on a node, it highlights it. When I right click on a node it doesn't move the highlight from the last selected node.
I have code in the treeview MouseDown for a context menu.
The menu items are bases on the SelectedItem.Key of the treeview - which is still the last selected node.
How do I get around this problem??
Thanks
Re: Treeview Highlight Problem.
Does the highlighting work if you comment out the code in the MouseDown event?
Re: Treeview Highlight Problem.
Quote:
Originally Posted by MartinLiss
Does the highlighting work if you comment out the code in the MouseDown event?
Yes it does.
Does this mean that I have to put this code somewhere else?
I have it in mousedown, not mouseup because I want to see if the user is calling the context menu before the node loads a file into a RTB.
Re: Treeview Highlight Problem.
Please post the MouseDown code.
Re: Treeview Highlight Problem.
Quote:
Originally Posted by MartinLiss
Please post the MouseDown code.
Here it is:
vb Code:
Private Sub tvwCode_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
With tvwCode
Select Case Left(.SelectedItem.Key, 1)
Case Is = "S"
rcmitmAddNewNode.Enabled = True
rcmitmDeleteNode.Enabled = False
rcmitmReNameNode.Enabled = False
ShowTvwMenu
Case Is = "N"
rcmitmAddNewNode.Enabled = True
rcmitmDeleteNode.Enabled = True
rcmitmReNameNode.Enabled = True
ShowTvwMenu
Case Is = "C"
rcmitmAddNewNode.Enabled = False
rcmitmDeleteNode.Enabled = True
rcmitmReNameNode.Enabled = True
ShowTvwMenu
Case Else
rcmitmAddNewNode.Enabled = False
rcmitmDeleteNode.Enabled = False
rcmitmReNameNode.Enabled = False
ShowTvwMenu
End Select
End With
End If
End Sub
Re: Treeview Highlight Problem.
Can you also please post the code for ShowTvwMenu?
Re: Treeview Highlight Problem.
Quote:
Originally Posted by MartinLiss
Can you also please post the code for ShowTvwMenu?
Don't know if this helps much :ehh:
vb Code:
Private Sub ShowTvwMenu()
PopupMenu TvwMenu
End Sub
Re: Treeview Highlight Problem.
Put this at the end of the MouseDown code.
tvwCode.SelectedItem = tvwCode.HitTest(x, y)
Re: Treeview Highlight Problem.
... or perhaps right after
If Button = vbRightButton Then
Re: Treeview Highlight Problem.
thans Martin, I will give it a go. :)
Re: Treeview Highlight Problem.
Quote:
Originally Posted by MartinLiss
... or perhaps right after
If Button = vbRightButton Then
Yep, this one worked thanks. :thumb: