stuck: cant move to another TreeNode by rightclicking
I want to be able to change the selected node of a treeView by rightclicking on it, but seems like I cant do it.
the very odd thing is that when you right click on a node, it is highlighted as long as you dont release the mouse button. If you release the mouse button, the focus goes back to the last node.
I'm probably doing something really wrong, but whatever I'm doing, I cant figure it out. I even started a new project just to test and see if this would happen to another project, but same problem.
some help is appreciated
(If you're wondering why I want to do this: when the user right-clicks on an item, I want that item to be selected and then I want a popup menu to be shown. But TreeView.SelectedNode doesnt point to the right node at the time of the right click, nor after it )
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
copy pasted your code in a new project with only a treeview. no it doesnt work.... try this with the same code:
when you run the program, let one of the nodes be selected, then rightclick on ANOTHER node. I want the messagebox to show the name of the node that you just rightclicked...
right now I'm doing something like this: I have a TreeView_MouseUp event. I check the x and y coordinate of the mouseclick and with TreeView.GetNodeAt(x,y) I figure out which node was clicked. (and I also have to manually set that node to TreeView.SelectedNode )
VB Code:
Private Sub tvwItems_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tvwItems.MouseUp
If (e.Button = MouseButtons.Right) Then
Dim aNode As TreeNode = tvwItems.GetNodeAt(e.X, e.Y)
tvwItems.SelectedNode = aNode
cmnuItem.Show(tvwItems, New Point(e.X, e.Y))
End If
End Sub
well it works now but it seems redundant. I feel like I'm missing something here
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!