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

Deleting item in the tree list hierarchy

2 Answers 64 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 24 Dec 2010, 09:56 AM
Hi,
I'm trying to delete an item in the tree hierarchy.

       private void ButtonRemove_Click(object senderRoutedEventArgs e)
        {
            if (DialogRadTreeListView.SelectedItem != null)
            {
                DialogRadTreeListView.Items.Remove(DialogRadTreeListView.SelectedItem);

            }

        }
I believe the above code only deletes if the SelectedItem is in the first level of DialogRadTreeListView.Items.
If SelectedItem is several levels deep, "Remove" won't find it.
Any ideas how I can delete an item in this case?

Thanks.

-Chris

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 27 Dec 2010, 11:13 AM
Hi Chris ,

Indeed this code would work over the root collection only.  ( as RadTreeListView.Items contains only the root items) .
You will need to recursively find the item down the tree structure and remove it from its parent collection .

I can not give a specific sample code as it is highly dependant on your data structure.

In case you have troubles implementing this , please send me  some code illustrating the structure of your hierarchical data and I am sure we can think of some solution.

Regards,
Pavel Pavlov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Chris
Top achievements
Rank 1
answered on 27 Dec 2010, 11:25 AM
Hi, Pavel,
I guess I could write a helper function to iterrate over the items hierarchy, however, I inclined to think that it should be a part of RadTreeListView since it's built for such functionality.
Wouldn't you agree?

Thanks.
-chris

Tags
TreeListView
Asked by
Chris
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Chris
Top achievements
Rank 1
Share this question
or