Event SelectedNodeChanged does not fired

5 posts, 1 answers
  1. Thomas
    Thomas avatar
    22 posts
    Member since:
    Oct 2012

    Posted 09 Jan 2013 Link to this post

    I have RadTreeView with  MultiSelect = true;  When I’m programmatically select any node in tree like

    radTreeView.Nodes[0].Nodes[0] = true;

    radTreeView.Nodes[0].Nodes[1] = true;


    I expect then event SelectedNodeChanged will be fired, but it isn’t. It is a big problem, because I can’t handle when my nodes being selected.

    We are using Telerik RadControls_WinForms_2012_3_1211

    p.s. when I select node by this way: radTreeView.SelectedNode = radTreeView.Nodes[0].Nodes[1], event fires successfully, but using this method I can’t select multiple nodes from code.

    How do you suggest to resolve this?
  2. Answer
    Anton avatar
    167 posts

    Posted 11 Jan 2013 Link to this post

    Hi Thomas,

    Thank you for the writing.

    Currently the SelectedNodeChanged event is firing only for current node change which is bug. We already have a related PITS item: http://www.telerik.com/support/pits.aspx#/details/Issue=12205 . Feel free to add your vote for it.

    Currently, you can use the following workaround:
    1. Create custom tree node that inherits the RadTreeNode
    2. Via reflection call the OmSelectedNodeChanged method of the tree view when "Selected" property of the node is changed. This will fire the SelectedNodeChanged event of the tree view.
    public class MyRadTreeNode : RadTreeNode
        public MyRadTreeNode(string text)
            : base(text)
        private readonly static MethodInfo OnSelectedNodeChangedMethodInfo =
            typeof(RadTreeViewElement).GetMethod("OnSelectedNodeChanged", BindingFlags.NonPublic | BindingFlags.Instance, null,
            new Type[] { typeof(RadTreeNode) }, null);
        protected override void OnNotifyPropertyChanged(PropertyChangedEventArgs args)
            if (args.PropertyName == "Selected" && this.TreeViewElement != null)
                OnSelectedNodeChangedMethodInfo.Invoke(this.TreeViewElement, new object[] { this });

    3. Use your custom nodes instead the default ones. If your RadTreeView is using data source and the nodes are creating automatically you can subscribe to CreateNode event of the grid and replace them with the custom ones:
    void radTreeView1_CreateNode(object sender, CreateTreeNodeEventArgs e)
        e.Node = new MyRadTreeNode(e.Node.Text);
    If you are creating your nodes manually you can use the following example:
    RadTreeNode Node1 = new RadTreeNode("Node1");
    RadTreeNode Node2 = new RadTreeNode("Node2");
    RadTreeNode Node3 = new MyRadTreeNode("Node3");
    RadTreeNode Node4 = new MyRadTreeNode("Node4");

    Attached is a sample project that comprises the code above.

    I hope this information helps and please excuse us for the introduced inconvenience.

    Kind regards,
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. DevCraft R3 2016 release webinar banner
  4. Stephen McDaniel
    Stephen McDaniel avatar
    35 posts
    Member since:
    Mar 2008

    Posted 26 May 2015 Link to this post

    I ran into this same problem and was using the code provided by Telerik for a while.  However, I just upgrade to the latest version (Q1 2015 SP1) and it appears the signature of OnSelectedNodeChanged has changed so the reflection logic started breaking.  Instead, I've started using the following code and it works:

    private static readonly MethodInfo OnSelectedNodeChangedMethodInfo =
            BindingFlags.NonPublic | BindingFlags.Instance, null,
            new Type[] { typeof(RadTreeNode), typeof(RadTreeViewAction) }, null);
    protected override void OnNotifyPropertyChanged(PropertyChangedEventArgs args)
        if (args.PropertyName == "Selected" && TreeViewElement != null)
            OnSelectedNodeChangedMethodInfo.Invoke(TreeViewElement, new object[] { this, RadTreeViewAction.ByMouse });

     I randomly chose RadTreeViewAction.Mouse.  I'm not sure if another value would be more appropriate but this seemed to work.

    In my case, I'm actually not doing any selection via code.  My use case is as follows:

    • Have a tree view with Multi-Select = true
    • Select a Node by clicking on it - Event fires as expected
    • Unselect that same node by holding Ctrl key and clicking the node.  The node becomes unselected but the event doesn't fire

    With the workaround above, the event does fire.​


  5. Dess
    Dess avatar
    1561 posts

    Posted 29 May 2015 Link to this post

    Hello Stephen,

    Thank you for writing.

    I would like to note that the problem with selection when clearing the nodes was fixed in Q3 2013 SP2. Here is the feedback item for your reference.

    As to the case with multiple selection I confirm that it is an issue with RadTreeView. I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

    I have also updated your Telerik points.

    Should you have further questions, I would be glad to help.
    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 Feedback Portal and vote to affect the priority of the items
  6. Stephen McDaniel
    Stephen McDaniel avatar
    35 posts
    Member since:
    Mar 2008

    Posted 29 May 2015 Link to this post

    Great, thanks for the update!
Back to Top
DevCraft R3 2016 release webinar banner