Click to See Complete Forum and Search --> : treeview context menu
MetallicaD
Sep 12th, 2002, 11:53 AM
Hello.. I have a treeview that has an associated context menu.. When i right click on the treeview, the menu pops up.. correct!! however, if i right click on an element in the treeview that is currently not selected, it gets highlighted but the treeview still indicates that the .selectednode is the one that was previously highlighted...
it sounds like the selectitem event is not finishing before the contextmenu popup event fires..
any suggestions?
thanks
-Matt
MetallicaD
Sep 12th, 2002, 11:53 AM
also..
is there an property that I can use to get the currently highlighted element instead of the selected one?
thanks
-mcd
MetallicaD
Sep 12th, 2002, 12:00 PM
Ok.. i found the same issue on this threat: http://www.dotnet247.com/247reference/msgs/25/129525.aspx
I used their solution and it works.. now the question is, is this a flaw in the framework? If so, will it be fixed?
Thanks,
-mcd
Vahid
Sep 12th, 2002, 06:40 PM
I dont test your issue, so I write this blind. If there is any mistake, forgive me.
I dont think about this as a flaw, because this has easy workarounds, simply handle the Click event and show the context menu by code instead of setting the ContextMenu property. Just one line! I don't think treeview has another way to get the selected node (I'm not sure).
Finally: God bless Metallica, James, Kirk, Lars and JASON:cool: :cool: :cool:
MetallicaD
Sep 12th, 2002, 08:24 PM
Vahid... thanks for the reply.. Actually, on that link I provided, there is an easy way to do this with the context menu linked directly to the treeview:
Private Sub tvwFields_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles tvwFields.MouseDown
If e.Button = MouseButtons.Right Then tvwFields.SelectedNode =
tvwFields.GetNodeAt(New Point(e.X, e.Y))
End Sub
This works pretty good.. It just changes the selected node to the one you rightclicked on, then the context menu fires
thanks,
-matt
PT Exorcist
Sep 12th, 2002, 10:39 PM
i remember programming in vb6 and that error also happened a lot
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.