How to get Highlighted Node from TreeView?

goodmorningsky

Centurion
Joined
Aug 18, 2003
Messages
172
I want to get Highlighted Node from TreeView.
TreeView.SelectedNode doesn't return the one highlighted.
When you select node by left mouse button, SelectedNode is same as hightlighted Node. But, if you select it by Right mouse button, SelectedNode doesn't return the one hightlighted.

How can I get it?
Thank you all..
 
On the mousedown event, I would store a reference to the node returned by TreeView.GetNodeAt(e.X, e.Y), since the node under the mouse cursor is the one that will be selected, then on the context menu handlers (or wherever else you need) use that node you got from TreeView.GetNodeAt(e.X, e.Y) instead of TreeView.SelectedNode().

Sometimes what I do to simplify things is just select the node that they right-click in the mousedown event, i.e. TreeView.SelectedNode = TreeView.GetNodeAt(e.X, e.Y)
 
Back
Top