Deleting TreeView subitems

2 posts, 0 answers
    M STOLYAR avatar
    12 posts
    Member since:
    Dec 2010

    Posted 29 Sep 2011 Link to this post

    For example, we have TreeView with 2 nodes: 1st node is root, 2nd node is child of 1st.
    Every node that is contained in TreeView.Items collection can be easily deleted by:
    1st node can be easily deleted by that code. But 2nd node cannot, because it is not contained in TreeView.Items collection.
    How to delete any subitem of TreeView without going to recursion whole tree?
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 03 Oct 2011 Link to this post

    Hello M Stolyar,

     You can delete the First_Item's first child by the following code:
    (treeview.Items[0] as RadTreeViewItem).Items.RemoveAt(0);
    This will work when your RadTreeView is not bound. Please let us know if this fits in your scenario.

    Best wishes,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top