Context menu popup on treeview node returning wrong selected node

C

Claire

I've a treeview control containing a root node with several children on a
windows form.
I select a node with a left mouse button click.
I then select one of the other nodes with right mouse click to bring up my
context menu. The Popup event of this enables menu items depending on the
node selected.
The new node highlights, and my context menu pops up but I noticed that the
enabled state of the menu items was incorrect.
Tracing into my treecontextmenu_popup event the tree.selectednode is wrongly
shown to be the old node and not the new one. But the new one is
highlighted.
Has anyone got a solution to this please?

(Hideselection = false. Hottracking = false, drawmode=normal)
 
T

TheSteph

You have to manually select the node when right-clicking it and before
showing your popmenu; even if this node SEEMS to be already selected by your
right-click.

Steph.
 
C

Claire

Thanks Steph,
yes I've had to add code in the node onclick event to set the selected node
and it now works as I expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top