473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

loading treeview dynamically is very slow

Rather than load all my data into the treeview I am loading when a
level-1node gets expanded (for the first time).
To set up the code below, I've added a single child node for each
level-1node, just so that I can get the "+" and the capability to
expand.
So the first time I click on any level-1 node, it loads 30 child nodes.

The problem is how slow this is. To me it should be almost
instantaneous. It takes 2-3 seconds, which doesn't sound like much,
but believe me, it's irritating. The scroll bar rolls down the screen.
Once the nodes are populated, expanding and collapsing the parent node
is suitably quick.

Any ideas on at least making this appear quicker?
----------------
Private Sub myTreeView_AfterExpand(ByVal sender As Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles myTreeView.AfterExpand

Dim classNode As TreeNode
Dim testCtr As Integer

If e.Node.Nodes.Count = 1 Then
If e.Node.Text = e.Node.Nodes(0).Text Then
e.Node.Nodes.Clear()
For testCtr = 1 To 50
classNode = e.Node.Nodes.Add(testCtr.ToString)
Next
End If
End If
End Sub

Nov 29 '06 #1
3 5562

Bracket all adds with this:

myTreeView.BeginUpdate ()

..............
..............

myTreeView.EndUpdate ()
Nov 29 '06 #2

cowznofsky ha scritto:
Rather than load all my data into the treeview I am loading when a
level-1node gets expanded (for the first time).
To set up the code below, I've added a single child node for each
level-1node, just so that I can get the "+" and the capability to
expand.
So the first time I click on any level-1 node, it loads 30 child nodes.

The problem is how slow this is.
See if this improves (vb2005):

Private Sub myTreeView_AfterExpand(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.TreeViewEventArgs) _
Handles MyTreeView.AfterExpand

Dim testCtr As Integer
Dim SubNodes As New List(Of TreeNode)

If e.Node.Nodes.Count = 1 Then
If e.Node.Text = e.Node.Nodes(0).Text Then
e.Node.Nodes.Clear()
For testCtr = 1 To 50
SubNodes.Add(New TreeNode(testCtr.ToString))
Next
e.Node.Nodes.AddRange(SubNodes.ToArray)
End If
End If

End Sub

Nov 29 '06 #3
Ah, much better. Thanks!

Robinson wrote:
Bracket all adds with this:

myTreeView.BeginUpdate ()

.............
.............

myTreeView.EndUpdate ()
Nov 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dale cyr | last post by:
nick: hope i'm not stating the obvious for you, but you *are* aware, i presume, that your loading app wants to find the loaded app in the loading app's runtime directory, or a sub directory of...
3
by: aspnet guy | last post by:
my asp.net website is slow at my work machine but very fast at home. My work uses a firewall. Can that slow down the loading of web forms? are there any "common" things I can try to get it to...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
5
by: marfi95 | last post by:
I have a form that has a left and right panel. In the left panel is a treeview. The right panel I want to change dynamically based on the type of node selected. What I'm doing is loading the...
5
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
We have a page that is loading very slow. There is not a lot of data, not a lot of users are connected at the same time and the page does not produce an error, so I am not sure where to start to...
1
by: =?Utf-8?B?QWRhbQ==?= | last post by:
I'm having a problem loading an Icon into an ImageList. When I load the icon directly it works fine, like this: Icon sourceIcon = << Get an icon from somewhere... >>;...
2
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Now we have to load the whole company's organizational relationships into one TreeView which has at lest 6~7 layer and including 300~400 nodes.In every node,there is a checkbox. So we need...
2
by: =?Utf-8?B?QU5V?= | last post by:
I have a tree view which i load completely at the time of my webpage load. When i click on the + signs of the parent nodes, it expands to show all of its children. Similarly, when i click on the...
1
by: Christian Resma Helle | last post by:
Hey guys, I'm working on an AJAX Enabled ASP.NET Web application. I have a TreeView web control and an PlaceHolder web control. My PlaceHolder is inside an UpdatePanel and AsyncPostBacks are...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.