I'm not sure if this is the correct forums, please move if necessary.
I am using the UltraTreeView and when right click a tre item that is not selected. I need to tell the control what the currently hovered over item is without reseting the currently selected items.
For instance rows 2,3, and 5 are selected and user rights click on row 3. So when I show the context menu on right click it should be based row 3.
When I only have 1 item selected its easy by setting the selected node to the node the cursur is hanging over, but when multiple nodes are selected I need a way to tell the menu which item the context menu should be based on.
Any ideas?
Thanks,
Nick
Thanks for the reply.
I actually solved it about an hour ago.
I caught the item inside the ContextMenuOpening event. From there I manually changes the selected node.
Thanks for taking the time,
For any who stumble upon this in ContextMenuOpening use this code to find the node to replace. where utEq is the actual Tree Control
UltraTreeNode currentNode = utEq.GetNodeFromPoint(p);
then set it
// If a node is found then set as current view
{
utEq.SelectedNodes.Clear();
}
Hi Nick,
How are you displaying the ContextMenu? Are you doing it in code, or are you just setting the ContextMenu property on the control?
Either way, you will probably need to determine the node under the mouse using the GetNodeFromPoint method of the tree. If you are shoing the context menu yourself, this will be easier, since you will probably be using the MouseUp event and you will have the mouse coords. If you are just using the ContextMenu property, then it will be a little trickier, since you will need to convert the current mouse position into control coords.