how to get the parent name when selecting the child

2 posts, 0 answers
  1. dCODE
    dCODE avatar
    18 posts
    Member since:
    Jan 2010

    Posted 30 Mar 2010 Link to this post

    hi

    am using rad tree view, i want to get the parent value, when am selecting a child
    i mean, when i click on sub items in the tree i can get the values by selected items, but i want to get the  child value and corresponding parent value when am cliking the child. how i can do it
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 31 Mar 2010 Link to this post

    Hi dCODE,

    In your case it is better to use the RadTreeView SelectedContainer property, instead of the SelectedItem property. After you get the SelectedContainer you can use the NextItem, PreviousItem, ParentItem properties of the RadTreeViewItem to get the next, previous and parent items accordingly. If you need to get all of the children of the currently selected item you can use the ItemsSource property.

    RadTreeViewItem selectedContainer = treeView.SelectedContainer;        
    RadTreeViewItem nextItem = selectedContainer.NextItem;
    RadTreeViewItem previousItem = selectedContainer.PreviousItem;
    RadTreeViewItem parent = selectedContainer.ParentItem;
    IEnumerable childCollection = selectedContainer.ItemsSource;


    I prepared an example for you. Please take a look at it and let me know if it helps or if your scenario requires a different approach.

    All the best,
    Tina Stancheva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top