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

how to get the parent name when selecting the child

1 Answer 125 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
dCODE
Top achievements
Rank 1
dCODE asked on 31 Mar 2010, 02:53 AM
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

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 31 Mar 2010, 05:27 PM
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.
Tags
TreeView
Asked by
dCODE
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or