Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / November 2006

Tip: Looking for answers? Try searching our database.

loading treeview dynamically is very slow

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cowznofsky - 29 Nov 2006 19:53 GMT
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
Robinson - 29 Nov 2006 21:00 GMT
Bracket all adds with this:

myTreeView.BeginUpdate ()

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

myTreeView.EndUpdate ()
cowznofsky - 30 Nov 2006 15:20 GMT
Ah, much better.  Thanks!

> Bracket all adds with this:
>
[quoted text clipped - 4 lines]
>
> myTreeView.EndUpdate ()
tommaso.gastaldi@uniroma1.it - 29 Nov 2006 23:06 GMT
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).
[quoted text clipped - 5 lines]
>
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.