This is a migrated thread and some comments may be shown as answers.
Deleting TreeView subitems
1 Answer 15 Views
This is a migrated thread and some comments may be shown as answers.
M STOLYAR
Top achievements
Rank 1
M STOLYAR asked on 29 Sep 2011, 08:53 AM
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:
treeview.Items.Remove(treeview.SelectedItem);
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?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 03 Oct 2011, 03:45 PM
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 >>

Asked by
M STOLYAR
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or