This is a migrated thread and some comments may be shown as answers.

Right-click changes selected node

7 Answers 240 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 23 Aug 2010, 11:43 PM
In another forum post, it was implied that right-clicking on a tree node did not change the selected node (and fire SelectedNodeChanged) but it appears that in my TreeView is does.

Is there any way to disable this behavior?  I am using the right-click to launch a context menu but do not want the selected node to change.

I'm not using multiselect.

7 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 25 Aug 2010, 02:05 PM
The tree view doesn't react on the right mouse click. Are you changing the node.checked property in anything like the SelectedNodeChanging event?

Richard
0
Troy
Top achievements
Rank 1
answered on 25 Aug 2010, 09:28 PM
No, I'm not using SelectedNodeChanging at all.  I am using ContextMenuShowing but all I do there is set a variable to the clicked node.

When I right-click on any tree node, SelectedNodeChanged fires, followed by ContextMenuShowing.  The only other events I'm using are some of the drag/drop events, none of which fire on right-click.

I'm using version 2010.1.10.504.
0
Boryana
Telerik team
answered on 27 Aug 2010, 08:52 AM
Hello everyone,

Thank you for writing.

At the moment RadTreeView changes its selection on mouse right-click and shows the context menu of the selected node. This behavior is not quite right and our team would like to apologize for the caused inconvenience.

I would like to let you know that we decided to create a brand new RadTreeView control designed to replace and extend the functionality of its ancestor. It will introduce new  features, greater flexibility, and better performance. For example, one exciting improvement of the new control will be virtualization, which will allow you to load a great number of nodes without any performance concerns. More importantly, it will address all issues introduced in the current RadTreeView including the one you are experiencing. This control is part of our road map and although we cannot guarantee it, we will do our best to introduce it in Q3 2010.

At the moment, the only workaround I can suggest is illustrated in the attached sample project. I hope you will find it useful.

Let me know if I can assist you further.

All the best,
Boryana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sonya L
Top achievements
Rank 1
answered on 24 May 2011, 04:36 PM
It looks like this solution no longer works for 2011 Q1 SP1, since SelectedIndexChanging/Changed fires before MouseDown and NodeMouseDown.  How can I accomplish this in the new version of the controls?  Thanks!
0
Boryana
Telerik team
answered on 25 May 2011, 04:51 PM
Hi Sonya L,

Thank you for writing.

The latest version of our controls allows the implementation of the original scenario suggested in the forum thread. The attached sample project illustrates how to show a context menu for every right-clicked node without changing the selection. Please note that in order to show a context menu for a non-selected node, you will need to assign a custom menu. For further details please refer to the attached file.

Let me know if I can assist you further.

Best wishes,
Boryana
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Sonya L
Top achievements
Rank 1
answered on 25 May 2011, 10:38 PM
Is there a way to use this solution, and also have ContextMenuOpening fire?  I'm using ContextMenuOpening to save the node that is right-clicked, and also to set some properties of the context menu (disabling menu options for certain nodes, etc).  With this solution, ContextMenuOpening does not fire if the node is not selected when you right-click on it.  Thanks for your help!
0
Boryana
Telerik team
answered on 31 May 2011, 10:03 AM
Hello Sonya L,

Thanks for writing back.

The ContextMenuOpening event will fire only for selected nodes. In this sense you will not be able to use this event for the context menu of the non-selected nodes. I would recommend creating a custom context menu in an extended RadTreeView class. This context menu will be shown for both selected and non-selected nodes. You will also be able to get the right-clicked node in the extended implementations.

Please refer to a modified version of the sample project. If you have additional questions, feel free to contact me.

Kind regards,

Boryana
the Telerik team

 

Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
Treeview
Asked by
Troy
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Troy
Top achievements
Rank 1
Boryana
Telerik team
Sonya L
Top achievements
Rank 1
Share this question
or