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

How search an unique node by key???

1 Answer 168 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Romell
Top achievements
Rank 1
Romell asked on 12 Jul 2012, 09:31 PM
Hi

The idea is this: based on a dataset generated a tree structure but I found the following issues

1 - There is not a unique Key property by item or node... or is the property "Name"?
2 - Using the name property FindName method seems not to work ... so for items already included, this method always returns "Nothing" and the item is again included.

This process is generated immediately to the constructor of the class or window, ie, in the Sub Main exite a method that executes the code...

                    For Each currentRow As DataRow In myDataset.Tables(0).Rows

                        Dim currentItem As New RadTreeViewItem
                        With currentItem
                            .Header = currentRow("ObjectName").ToString.ToUpper.Trim
                            .IsEditable = False
                            .IsEnabled = True
                            .Name = .Header
                        End With

                        Dim myObject As RadTreeViewItem = Me.ObjectTypeTree.FindName(currentRow("ObjectName").ToString.ToUpper.Trim)

                        If myObject Is Nothing Then
                            Me.ObjectTypeTree.Items.Add(currentItem)
                        End If

currentItem  = Nothing
myObject  = Nothing

                    Next

 So how I can solve the case described in items 1 and 2.

In advance, thank you all ....

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 17 Jul 2012, 11:46 AM
Hi Romell,

The RadTreeViewItems don't have a key property but if I understand your questions correctly, what you need to find is a way of getting a specific RadTreeViewItem by a certain key. If this is indeed the case, then it would be best to use the path to that item and the RadTreeView.GetItemByPath method. However, as this method only works if the item is loaded, you may need to create a custom method for accessing a RadTreeViewItem which hasn't been realized yet. You can have a look at this blog post describing how to bring into view a RadTreeViewItem. In the sample solution attached in the blog, you can find a custom implementation for getting an item using its name - the implementation of the GetItemByName() method.

I hope this information will help you implement your scenario. Please let us know if we can further assist you.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
Romell
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or