Wrong number of nodes in SelectedNodes.

2 posts, 0 answers
  1. Mateusz
    Mateusz avatar
    11 posts
    Member since:
    Jul 2012

    Posted 04 Mar 2014 Link to this post

    Hi,

    Create new form and paste code below. 
    Run form, expand "root" node and select any item. SelectedNodeChanged event should write to console value "1".
    Then click button to rebuild re-build the tree, again expand "root" node and select any item.
    This time SelectedNodeChanged will write to console value: "2".

    private void Form1_Load(object sender, EventArgs e)
    {
        RadButton b = new RadButton();
        b.Text = "Rebuild";
        b.Dock = DockStyle.Top;
        b.Click += b_Click;
     
        rtv = new RadTreeView();
        rtv.SelectedNodeChanged += rtv_SelectedNodeChanged;
        rtv.Dock = DockStyle.Bottom;
     
        this.Controls.Add(b);
        this.Controls.Add(rtv);
     
        Rebuild(rtv);
    }
     
    RadTreeView rtv = new RadTreeView();
     
    private void rtv_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
    {
        Console.WriteLine(rtv.SelectedNodes.Count);
    }
     
    private void b_Click(object sender, EventArgs e)
    {
        Rebuild(rtv);
    }
     
    private void Rebuild(RadTreeView rtv)
    {
        rtv.Nodes.Clear();
        rtv.Nodes.Add("root");
        rtv.Nodes[0].Nodes.Add("level 1 item 1");
        rtv.Nodes[0].Nodes.Add("level 1 item 2");
        rtv.Nodes[0].Nodes.Add("level 1 item 3");
        rtv.Nodes[0].Nodes.Add("level 1 item 4");
     
        // this don't work
        rtv.SelectedNodes.Clear();
    }
  2. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 05 Mar 2014 Link to this post

    Hi Mateusz, 

    Thank you for contacting us. 

    We are aware of this issue with our RadTreeView. The issue was fixed in Q3 2013 SP1 (2013.3.1127) and one way to avoid it is to upgrade to the latest version. 

    If you do not want to upgrade your version of UI for WinForms you can use the workaround from feedback item: FIX. RadTreeView - Clearing the Nodes does not clear selected nodes

    Hope this will help you. Let me know if you have any another questions.

    Regards,
    Ralitsa
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top