Quote:
> I am having problems trying to get a pop-up to behave correctly for a
> treeview. When the right mouse button is clicked, I want the current node to
> be selected and the pop-up to display. When the left button is clicked, the
> normal treeview behavior should occur such as selection or branch expansion.
> If I use the following code, the left and right mouse buttons work correctly
> but the node under the mouse pointer is not selected. The popup works against
> the currently selected node, whatever that happens to be.
> Private Sub tvtreeview_Mousedown(Button As Integer, Shift As Integer, x As
> Single, Y As Single)
> If Button <> vbRightButton Then Exit Sub
At this point, you should insert
Set tvTreeView.SelectedItem = tvTreeView.HitTest(x, y)
If tvTreeView.SelectedItem Is Nothing Then Exit Sub
Then go on with the rest of your code.
--