TreeView is very slow. Any performance tips?

0
0

 

I’m using the treeview to visualize  a filesystem based on a directory list. This list came from a hardrive.

I feed this list of strings  to the function shown below.

It is the same function from the desktop app.

The desktop app can  populate  the winforms treeview  with  500,000 items and display them without any lag.

The Wisej Treview cant even display 5,000 items without choking.

 

How can I get better performance?

 

Snippet

TreeView1.Nodes.Clear()
        TreeView1.Nodes.Add(PopulateTreeNode2(paths, "\"c))

Snippet

Public Function PopulateTreeNode(paths As String(), pathSeparator As String) As TreeNode
       Dim thisnode As New TreeNode()
 
       If paths Is Nothing Then
           Return Nothing
 
       Else
 
           Application.StartTask(Sub()
 
 
                                     thisnode.Text = My.Settings.JobName
                                     Dim currentnode As TreeNode
                                     Dim cachedpathseparator As Char() = pathSeparator.ToCharArray()
                                     For Each path As String In paths
                                         currentnode = thisnode
                                         For Each subPath As String In path.Split(cachedpathseparator)
                                             If currentnode.Nodes(subPath) Is Nothing Then
                                                 currentnode = currentnode.Nodes.Add(subPath, subPath)
                                             Else
                                                 '   currentnode = currentnode.Nodes(subPath)
                                             End If
                                             Application.Update(TreeView1)
 
                                         Next
                                         Application.Update(Me)
                                         
                                     Next
 
                                 End Sub)
 
 
       End If
 
 
       MsgBox("OK")
       Return thisnode
 
   End Function
  • You must to post comments
0
0

Hi,

What about using the DataGridView control with VirtualMode? You can also build up a tree structure with this control and have the power to only show the visible nodes on client.

Jens

  • You must to post comments
0
0

Load  only 1 level, set the node to ShowLoader true and IsParent true and load the child nodes only on demand when the node is expanded. Try the Wisej.Web.FileOpenDialog component. You can also set VirtualScroll to true on the TreeView (which is experimental and has some issues). In general 5000 nodes result in 50,000 elements in the browser.

  • Lennox Robinson
    Thank you for the reply. Wisej.Web.FileOpenDialog is not needed because the filepath strings are being displayed as a result of a lucene search in a DataGridView. I grab the strings I need from the grid. I thought about loading the nodes on-demand but that would require storing the strings in memory or in some sort of table so they can be queried in addition to populating the treeview. I really dont want to add anymore overhead. I dont know, I might have to abandon this particular project or scrap the treeview feature. Perhaps I can wrap the aspnet treeview instead?
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.