Aleksey wrote:
Hi, All!
I have a problem with TreeView component. My TreeView consists of
two nodes Node1 and Node2. On click of right mouse button TreeView
has event. In this event I check wich node is selected. At the start
Node1 is selected. But when I do right click on Node2 the selected
node remain Node1. It changed only after left click.
Q: How can I check on wich node was right click? Or how can I make
TreeView to change selected node by node that gets right click?
This is a problem with the treeview control. To solve it do:
In the MouseDown event, check if the mousebutton is the
rightmousebutton like:
if(e.Button==MouseButtons.Right)
{
// here select the node, like:
_myTreeView.SelectedNode = _myTreeView.GetNodeAt(e.X,e.Y);
// set the context menu for the treeview here. That is, if
// SelectedNode is of course not null
}
FB
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET:
http://www.llblgen.com
My .NET blog:
http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------