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

Load RadTreeViewItem

1 Answer 29 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
jean michel
Top achievements
Rank 1
jean michel asked on 21 May 2010, 03:31 PM
Hello,

I need to cover nodes of my treeview. Nodes is objects of the DtoHierarquiaAgrupamento class.
 
It follows the code below:
 foreach (Telerik.Windows.Controls.RadTreeViewItem item in RadHierarquia.Items)  
                {  
 
                    //codeblock  
                } 
 
Error:

Unable to cast object of type 'CCM7.DTO.DtoHierarquiaAgrupamento' to type 'Telerik.Windows.Controls.RadTreeViewItem'.

Thanks..!

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 21 May 2010, 04:05 PM
Hi jean michel,

RadHierarquia.Items collection contains items of type DtoHierarquiaAgrupamento. Therefore you need to modify the foreach like so:
foreach (DtoHierarquiaAgrupamento item in RadHierarquia.Items) 
   
 
        //codeblock 
   }
or you can do it like so:
foreach (var item in RadHierarquia.Items) 
    
  
         //codeblock 
    }

However, if you need to use the RadTreeViewItem containing the item, you can use the ContainerFromItemRecursive method of the RadTreeView:
RadTreeViewItem treeItem = myRadTreeView.ContainerFromItemRecursive(item);

Give this a try and let me know if it works for you.

Greetings,
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
jean michel
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or