473,804 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need advice with huge TreeView performance

I am generating a very large tree list in my program and while it's
performance is great once loaded it takes a really long time to load.

I create a root TreeNode "offline" and go through the process of
creating building up the tree from there. Only when I am done do I go
over to the actual TreeView object on my form and add the my root to
the TreeView. This sinlge step when I add my constructed root node to
the form's TreeView control takes a really long time. Constructing the
tree and all it's objects down from the root node took about 16 seconds
at which point all my work is basically done, but the form takes a
whopping 121 seconds to finally show the tree.

Does that sound normal? Is there ANYTHING I can do to speed this up? If
not, is there any way I can somehow show the user the progress of this
TreeView control loading up?

My tree nodes are very, very simple! Most of them are plain text no
more than 3 or 4 characters long. The most commplicated tree nodes are
plain text up to perhaps 80 characters long, and those are rare. It
really should be quick to load up. The data making up the tree is about
8 megs of text (uncompressed), and the program winds up taking around
250 megs.
Is there maybe a more lightweight tree control out there that you would
recommend if the .NET is too inefficient?

Or is there any optimaization you can think of I can try?

Oct 10 '06 #1
7 9701
Or is there any optimaization you can think of I can try?

A good solution might be to only fill the nodes that are currently expanded.
Then, fill the nodes on-demand as they are expanded by listening to the BeforeExpand.
I've used this technique with success in the past. The only trick is to add
a dummy child node to each collapsed node that has children and removing
the dummy node when the children are added in the BeforeExpand event handler.

Best Regards,
Dustin Campbell
Developer Express Inc.
Oct 10 '06 #2

Dustin Campbell wrote:
Or is there any optimaization you can think of I can try?

A good solution might be to only fill the nodes that are currently expanded.
Then, fill the nodes on-demand as they are expanded by listening to the BeforeExpand.
I've used this technique with success in the past. The only trick is to add
a dummy child node to each collapsed node that has children and removing
the dummy node when the children are added in the BeforeExpand event handler.

Best Regards,
Dustin Campbell
Developer Express Inc.
sounds like a good idea and I think I will try it. Just one thing, why
fill with dummy nodes? and what would that mean doing exactly? Just
creating an empty TreeNode object and adding it? I ask because if
that's what you meant then I might as well just add the real names
because the full text is really not much bigger than no text at all !

And how did you structure your data on the back end so that when a user
goes to expand some node you know exactly what to fill it with?

Oct 10 '06 #3
sounds like a good idea and I think I will try it. Just one thing, why
fill with dummy nodes? and what would that mean doing exactly? Just
creating an empty TreeNode object and adding it? I ask because if
that's what you meant then I might as well just add the real names
because the full text is really not much bigger than no text at all !
I find that the dummy node solution works well because it can be used as
an indicator that its parent still need to be filled with children. That
makes the code a bit easier to write.

Here's an example of what I'm talking about

Root
|
--First child (no children)
--Second child (has children)
-- Dummy node
--Third child (no children)

In order to make "Second child" expandable in the UI, it must contain at
least one node. And, since the data isn't loaded until the BeforeExpand is
fired for "Second child" we add a dummy node that indicates that "Second
child" needs to be filled. Consider this event handler code:

private void myTreeView_Befo reExpand(object sender, TreeViewCancelE ventArgs
e)
{
if (FirstNodeIsDum myNode(e.Node))
{
RemoveDummyNode (e.Node);
AddChildren(e.N ode);
}
}

Using a dummy node in the above code ensures that the children are only added
to the node once.
And how did you structure your data on the back end so that when a
user goes to expand some node you know exactly what to fill it with?
In a tree situation, I often find it easiest to just keep your data in some
sort of composite structure so that you can easily match the data to the
nodes.

Best Regards,
Dustin Campbell
Developer Express Inc.
Oct 10 '06 #4
A good solution might be to only fill the nodes that are currently expanded.
Then, fill the nodes on-demand as they are expanded by listening to the BeforeExpand.
I've used this technique with success in the past. The only trick is to add
a dummy child node to each collapsed node that has children and removing
the dummy node when the children are added in the BeforeExpand event handler.
The dummy node approach works well provided you don't have too many
nodes parented by any given node. If for example you have a 1000 nodes
under one parent node then you still have to load all 1000 (even though
you might only be displaying 30). The other disadvantage of the dummy
node approach is the disappearing expansion icon issue ie if a given
node doesn't have any children when the user clicks the expansion icon
the expansion icon then dissappears - this can be somewhat
disconcerting.

You might want to take a look at Infralution's Virtual Tree. It
addresses both of these issues and only loads the data actually
required to support the current display. This means it loads almost
instantly and has a minimal memory footprint even when viewing huge
datasources. You can get more information and download an evaluation
version from:

www.infralution.com/virtualtree.html

Regards
Grant Frisken
Infralution

Oct 10 '06 #5
"tman" <tl*****@gmail. comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
And how did you structure your data on the back end so that when a user
goes to expand some node you know exactly what to fill it with?
In addition to what Dustin wrote (his solution is almost exactly,
C#-statement-for-C#-statement what I did for a similar situation), I'll
point out that you just need to put in the dummy node whatever information
you need to tell you where to get the rest of the data.

In my case, I had code that was parsing a file that had an internal tree
structure. Each dummy node contained the file offset and length of the data
remaining to be parsed for that node. Then when it came time to expand that
node, it was a simply matter to read the data from the file and parse it
into the nodes necessary to fill that part of the tree (I only ever parsed
one level at a time, so expanding one dummy node often wound up creating a
bunch more dummy nodes one level lower :) ).

But what specifically you put in the dummy node just depends on what you
need in order to retrieve the data you skipped over earlier. Only you can
answer that question.

Note that to do the above, you wind up creating an actual dummy node class,
derived from the TreeNode class, so that you can actually insert an instance
of that class in the tree. Then, the tree control itself holds on to all
the dummy node instances for you, all ready to process later.

Pete
Oct 11 '06 #6
"Grant Frisken" <gr***@infralut ion.comwrote in message
news:11******** *************@c 28g2000cwb.goog legroups.com...
The dummy node approach works well provided you don't have too many
nodes parented by any given node. If for example you have a 1000 nodes
under one parent node then you still have to load all 1000 (even though
you might only be displaying 30).
I agree this is a potential issue. One can work around that with the
default control by only loading enough nodes to fill the current visible
portion of the control, and enough extra to provide some scrolling feedback.

That said, if you responded that the scrolling feedback is inaccurate and
misleading, I wouldn't disagree. The MSDN web site used to do something
like this for a few months recently, and I hated it. But still, it's a
possible option.

A more correct solution would be to somehow fix the scrollbars so that they
didn't require the tree view to be populated in order to correctly show the
range of data available in the tree view. I presume your custom control
does this.

Of course, even doing it that way, one runs into the problem that you are
then populating the tree view as it's being scrolled. Depending on where
the data is coming from, this may also be a poor user experience. The user
may prefer to wait a few seconds to get those 1000 nodes loaded, rather than
having to wait a quarter second for each one to load as it gets scrolled
into view. (That was certainly one of my major objections to the MSDN web
site implementation. ..in addition to not being able to scroll immediately to
the end, I had to wait for each little section of text to get loaded).
The other disadvantage of the dummy
node approach is the disappearing expansion icon issue ie if a given
node doesn't have any children when the user clicks the expansion icon
the expansion icon then dissappears - this can be somewhat
disconcerting.
IMHO, this is not an issue at all. The code should only be adding dummy
nodes when there is in fact additional data below the given node. Code that
creates a dummy node when no data is actually present below the given node
is buggy code, and not worth consideration here.

Pete
Oct 11 '06 #7
That said, if you responded that the scrolling feedback is inaccurate and
misleading, I wouldn't disagree. The MSDN web site used to do something
like this for a few months recently, and I hated it. But still, it's a
possible option.
Which is what I would say :-) It is also quite difficult and messy to
code this approach (aside from it's other user drawbacks).
A more correct solution would be to somehow fix the scrollbars so that they
didn't require the tree view to be populated in order to correctly show the
range of data available in the tree view. I presume your custom control
does this.
It is extremely difficult (if not impossible) do this with the standard
treeview. Our control (along with most other commercial controls) is
written from the ground up.
Of course, even doing it that way, one runs into the problem that you are
then populating the tree view as it's being scrolled. Depending on where
the data is coming from, this may also be a poor user experience. The user
may prefer to wait a few seconds to get those 1000 nodes loaded, rather than
having to wait a quarter second for each one to load as it gets scrolled
into view. (That was certainly one of my major objections to the MSDN web
site implementation. ..in addition to not being able to scroll immediately to
the end, I had to wait for each little section of text to get loaded).
For very slow datasources (ie web based retrieval) this may be an
issue. For data coming from the local hard disk or database this is
not an issue. VirtualTree has a TrackVertScroll property which if set
to false, means the display is not updated as the scrollbar is dragged
(only when it is dropped).
The other disadvantage of the dummy
node approach is the disappearing expansion icon issue ie if a given
node doesn't have any children when the user clicks the expansion icon
the expansion icon then dissappears - this can be somewhat
disconcerting.

IMHO, this is not an issue at all. The code should only be adding dummy
nodes when there is in fact additional data below the given node. Code that
creates a dummy node when no data is actually present below the given node
is buggy code, and not worth consideration here.
Actually there is a reason why you might choose to do this. The cost
to determine a given node has children can be significant -
particularly if I am adding say 100 child nodes to a given node. If
for each node I have to perform some kind of database query to find out
whether the node has any children (to work out whether I need to add
the dummy node below it) then this can have a significant performance
impact. Virtual Tree in this situation only generates queries for the
children that are actually displayed (maybe 30 or so) and so will be
much faster where there are large numbers of children of any given
node. Even so querying the nodes for children as they are displayed
can have an adverse affect on scrolling performance depending on your
data source. Virtual Tree has a LoadOnDemand option that allows you to
defer the query until the user actually clicks the expansion icon -
which of course may cause the icon to disappear if the node has no
children.

Oct 11 '06 #8

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

Similar topics

0
407
by: Apollo | last post by:
I have about 20K records that result from the following query. Front end for the database is ACCESS97 and pulling up 20K records makes a huge performance hit. For the form in question I am using PASSTHROUGH type query (the one that just passes everything straight to server without ODBC). NOTE: souce_for_inquiries_form is the TEMP table and is searchable in the from (it feeds a pull-down list). SELECT inquiries.inquiry_id,...
4
2310
by: Marquisha | last post by:
If this is off-topic, please forgive me. But I thought this might be the perfect spot to get some advice about how to proceed with a project. Working on a Web site design for a nonprofit organization, and I'm donating the work. Haven't done Web work in a while, and things have changed since I last did anything of this magnitude. I'm looking for a solution that will enable me to edit pages easily and in totally WYSIWYG fashion, while...
19
4115
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
2
5400
by: Joe | last post by:
I'm loading a TreeView with ~8900 root nodes and only a couple of child nodes giving a total of 8910 nodes. It takes several seconds for the tree to display. The method that populates the tree returns in < .5 seconds. Populating the tree in the Load event takes even longer than clicking a button after the screen has been loaded. try
2
1529
by: janhm | last post by:
Hey, I had a problem with adding xml into a treeview few month ago. The project got abandon, but im now working with it again. Here is my problem: I have an xml file containing: <?xml version="1.0"?> <kiosks> <kiosk>
4
2250
by: Aidan Marcuss | last post by:
I am seeing significant performance problems with the TreeView (from the Microsoft.Web.UI.WebControls namespace) when trying to data bind it on the server side. I set the TreeNodeSrc property and the TreeNodeTypeSrc property and then call the DataBind() method. I am setting each of these properties to a string of XML. As the payload grows, this becomes terribly slow. This is all server side. I've found that this may have to do with...
77
14454
by: Tark Siala | last post by:
hi i working with TreeView in VB6, and have good Properity Named (Key) with the Key i can goto Any Node i know hes Key. but in VB.NET i can find the Key :( please tell me where i can find the key in TreeView.Net... ----------------------------------------------- Best Regards From Tark
18
2345
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before. Here's the scenario: We have a base class with all virtual functions. We'll call this the Animal class. We then make two classes Fish and Bird that both inherit from Animal. In the program, we have a single array of Animal pointers that will...
4
2728
by: Bill McCormick | last post by:
Hello cSharpies, I'm building my 1st WPF app and I'd like to get off to a good start, so experienced advice I'm soliciting. The application is an explorer like tool with two (2) main sections: 1) a TreeView on the left and 2) a work Grid on the right (see XAML example below.) The TreeView will display a hierarchy of Groups and Items; there may be 1 or more Groups with the same set of Items. Selecting an Item from the TreeView will...
0
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.