By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

how to add mouse right-click event to tree w/out overriding defaul

P: n/a
by default when you right click a tree the control selects the node

if you add a right-click event (so that I can put sepearate ContextMenus
depending on what type of node the user clicked on) then that default
behavior is overrided, and it no longer selects the node the user
right-clicked on. Now my event is wrong because I want to use SelectedNode
but the SelectedNode turns out to be whatever was previously selected instead
of what the user just clicked on.

how do I solve this problem?
Oct 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <99**********************************@microsoft.co m>,
Mr******@discussions.microsoft.com says...
by default when you right click a tree the control selects the node

if you add a right-click event (so that I can put sepearate ContextMenus
depending on what type of node the user clicked on) then that default
behavior is overrided, and it no longer selects the node the user
right-clicked on. Now my event is wrong because I want to use SelectedNode
but the SelectedNode turns out to be whatever was previously selected instead
of what the user just clicked on.

how do I solve this problem?
Instead of handling the MouseDown event, you could inherit from the
TreeView and override the OnMouseDown method -- and make sure you call
base.OnMouseDown() first to let the base class do it's code first (which
should include selecting the node right-clicked on).

--
Patrick Steele
http://weblogs.asp.net/psteele
Oct 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.