How to handle TreeNode right click

J

Juan Romero

Hey guys, I have a small problem here....

I have a treeview control. I want to display a popup menu when the user
right clicks on a node. This is no problem, and I am able to make the popup
come out.

However, when I want to perform an operation based on the node selected, I
find that the node actually gets selected after the popup goes away. In
other words, if I right click a random item in the treeview and the user
selects an operation from the popup, the treeview's selectednode property is
NOTHING.

Only if I select the item with a click first, and then do the right click,
the selectednode property is ok (obviously).

How can I handle this?

Thanks in advance.
 
H

Herfried K. Wagner [MVP]

* "Juan Romero said:
I have a treeview control. I want to display a popup menu when the user
right clicks on a node. This is no problem, and I am able to make the popup
come out.

However, when I want to perform an operation based on the node selected, I
find that the node actually gets selected after the popup goes away. In
other words, if I right click a random item in the treeview and the user
selects an operation from the popup, the treeview's selectednode property is
NOTHING.

Only if I select the item with a click first, and then do the right click,
the selectednode property is ok (obviously).

Have a look at the TreeView's 'GetNodeAt' method:

<http://makeashorterlink.com/?K233612F3>
 

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