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

treeview performance / images

2 Answers 77 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
andi
Top achievements
Rank 1
andi asked on 13 Feb 2008, 03:36 PM
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()
        oDBC.Open()
        Dim da As New MySqlDataAdapter("SELECT * FROM Filesystem ORDER BY FolderName", oDBC)
        Dim dt As New DataTable
        da.Fill(dt)
        oDBC.Close()

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

        'bilder setzen für alle knoten
        'Me.setTreeViewImages(RadTreeViewFromTemplate.Nodes)
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
            Me.setTreeViewImages(tn.Nodes)
        Next
End Sub

2 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 14 Feb 2008, 09:38 AM
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,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
andi
Top achievements
Rank 1
answered on 14 Feb 2008, 11:11 AM
hello!

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

greetings, andi
Tags
Treeview
Asked by
andi
Top achievements
Rank 1
Answers by
Jordan
Telerik team
andi
Top achievements
Rank 1
Share this question
or