treeview performance / images

3 posts, 0 answers
  1. andi
    andi avatar
    34 posts
    Member since:
    Jan 2008

    Posted 13 Feb 2008 Link to this post

    after reading data for the treeview from database i use a recursive function which sets the image for each node. this takes a very long time because there is a huge tree...

    is there a better way to set the same image for all the nodes of the tree?

    below i've postet the two functions i use:

    Private Sub fillTreeViewFromTemplate()
            Dim da As New MySqlDataAdapter("SELECT * FROM Filesystem ORDER BY FolderName", oDBC)
            Dim dt As New DataTable

            Me.RadTreeViewFromTemplate.DisplayMember = "FolderName"
            Me.RadTreeViewFromTemplate.ValueMember = "FilesystemId"
            Me.RadTreeViewFromTemplate.ParentIDMember = "ParentId"
            Me.RadTreeViewFromTemplate.DataSource = dt

            'bilder setzen für alle knoten
    End Sub

    Private Sub setTreeViewImages(ByVal tnc As RadTreeNodeCollection)
            'für jede node das bild setzen
            Dim tn As RadTreeNode
            For Each tn In tnc
                tn.Image = My.Resources.folder
    End Sub

  2. Jordan
    Jordan avatar
    547 posts

    Posted 14 Feb 2008 Link to this post

    Hello Andi,

    After you set an image to a node in RadTreeView, the treeview is invalidated and all nodes arranged by a layout algorithm. In your case the layout algorithm executes for every node.

    You can set all the images in an batch update operation  by  calling tree.BeginUpdate() before you set the images and tree.EndUpdate() after you set the images.
    This way the layout algorithm of RadTreeView will execute only once.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft R3 2016 release webinar banner
  4. andi
    andi avatar
    34 posts
    Member since:
    Jan 2008

    Posted 14 Feb 2008 Link to this post


    thank you for your answer. i also found this way out in between.

    greetings, andi
Back to Top