Removing a tree node

2 posts, 0 answers
  1. Sonya L
    Sonya L avatar
    36 posts
    Member since:
    Dec 2009

    Posted 17 Jan 2011 Link to this post

    I have a treeview control bound to a BindingList.  If I call .Remove() on one of the tree nodes, should it delete the underlying item in the BindingList?  I checked the count before and after calling .Remove, and the count on the bindinglist is the same.  I want the item to be deleted, so what do I need to do differently?  Also, I have tried removing the items from the underlying BindingList, and have noticed that the tree nodes are not removed.  I can add nodes to the bindinglist, and they will show up as new tree nodes, but I am having issues with removal.  Thanks for any help!
  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 20 Jan 2011 Link to this post

    Hi Sonya L,

    This a known issue in RadTreeView. Currently, we are reimplementing our RadTreeView introducing a new data engine and virtualized UI. I am glad to inform you that this feature will be supported by default including all CRUD operations.

    For the time being, you must manually remove the attached item from the bound object and this automatically will remove the RadTreeNode item:

    using System;
    using System.ComponentModel;
    using System.Windows.Forms;
    namespace LabApp
        public partial class Form6 : Form
            BindingList<Person> persons;
            public Form6()
                this.persons = new BindingList<Person>();
                this.persons.Add(new Person(1, 0, "Peter"));
                this.persons.Add(new Person(2, 0, "Stefan"));
                this.persons.Add(new Person(3, 1, "John"));
                this.persons.Add(new Person(4, 2, "James"));
                this.persons.Add(new Person(5, 4, "Ivan"));
                this.radTreeView1.DataSource = this.persons;
                this.radTreeView1.ValueMember = "Id";
                this.radTreeView1.DisplayMember = "Name";
                this.radTreeView1.ParentIDMember = "ParentId";
            private void radButton1_Click(object sender, EventArgs e)
                if (this.radTreeView1.SelectedNode != null)
                    Person person = this.radTreeView1.SelectedNode.DataBoundItem as Person;
                    if (person != null)
            public class Person
                string name;
                int id;
                int parentId;
                public Person()
                public Person(int id, int parentId, string name)
           = id;
                    this.parentId = parentId;
           = name;
                public string Name
                    get { return name; }
                    set { name = value; }
                public int Id
                    get { return id; }
                    set { id = value; }
                public int ParentId
                    get { return parentId; }
                    set { parentId = value; }

    I hope this helps.

    All the best,
    Julian Benkov
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  3. DevCraft R3 2016 release webinar banner
Back to Top