Deleting item in the tree list hierarchy

3 posts, 0 answers
  1. Chris
    Chris  avatar
    42 posts
    Member since:
    Apr 2009

    Posted 24 Dec 2010 Link to this post

    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. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 27 Dec 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Chris
    Chris  avatar
    42 posts
    Member since:
    Apr 2009

    Posted 27 Dec 2010 Link to this post

    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

Back to Top