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

Wrong number of nodes in SelectedNodes.

1 Answer 21 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Mateusz
Top achievements
Rank 1
Mateusz asked on 04 Mar 2014, 11:00 AM
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();
}

1 Answer, 1 is accepted

Sort by
0
Ralitsa
Telerik team
answered on 05 Mar 2014, 01:20 PM
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!

Tags
Treeview
Asked by
Mateusz
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Share this question
or