TreeView performance

  • Thread starter Thread starter jgeissman
  • Start date Start date
J

jgeissman

I recently moved a VB application from VStudio 2005 to VStudio 2008 in
order to take advantage of some new classes. Performance of one bit
of the code -- displaying a TreeView -- now takes ten or more times as
long as before, from ~2 secs to ~30. Is this something that is known
to have changed between versions of VB? Are there any optimization
techniques I should be using?

Thanks,
Jim Geissman
 
I know of no differences between the versions.  One question that I do
have though is are you using Nodes.Add() or Nodes.AddRange().  Each one
causes the TreeView to redraw itself so you can imagine how important it
is to use AddRange() when possible.

Jason Newellwww.jasonnewell.net

Thanks for the tip. After further analysis, I see the time is taken
adding
the maybe 3000 nodes to their parent's Nodes object. After that is
finished, putting the top-level nodes on the TreeView itself, which
also
handles their children, takes essentially no time. But parsing the
input
and extracting both the TreeNodes and the members of a parallel node
tree that doesn't get displayed but contains additional data (each of
those nodes has a TreeNode member, and its constructor also
gets any children out of the input recursively) seems to go at a rate
of
about 90/sec on a 2.7 ghz 2-cpu machine, which doesn't seem
reasonable at all. I think I need to see what's going on at a
smaller
scale. Maybe the recursion is the problem, although it used to be
a lot faster!
 
Back
Top