How search an unique node by key???

2 posts, 0 answers
  1. Romell
    Romell avatar
    39 posts
    Member since:
    Feb 2012

    Posted 12 Jul 2012 Link to this post


    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
                            End If

    currentItem  = Nothing
    myObject  = Nothing


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

    In advance, thank you all ....
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 17 Jul 2012 Link to this post

    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.

    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top