472,958 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Adding nodes to a treeview only when needed

I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate it in background and/or when the nodes are required by the user either scrolling or performing some other action that would move the treeview window to a particular "unloaded" node in the treeview

Any advice on how to go about this? It seems I need a way of sensing a scroll event in the treeview control, but it does not appear that the treeview control exposes this event

Thanks for the help.
Nov 20 '05 #1
4 2250
* "=?Utf-8?B?cG1jZ3VpcmU=?=" <an*******@discussions.microsoft.com> scripsit:
I have a treeview with a lot of nodes. I want to load only the nodes
that are initially visible when the form loads, and then continue to
populate it in background and/or when the nodes are required by the user
either scrolling or performing some other action that would move the
treeview window to a particular "unloaded" node in the treeview.


Instead of doing that, you can add only the top-level nodes and dummy
subnodes (one level) where required. When the control is displayed to
the user, all branches of the tree are collapsed. If the user expands a
node, you remove the subitem (or change it) and add the appropriate
items.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
What you are looking for is a "virtual tree view". As far as I am aware,
the vanilla tree view in Forms wasn't written to perform this (or anything
much come to think of it!).

The approach really depends on how many items are in the root of your tree
view. If you have literally thousands, populating the tree still shouldn't
take all that long (I've tested mine with a full tree of over 6,000 items
and ok, it takes a couple of seconds, but it isn't too annoying). The
issue is what you are doing in order to fetch a given item. For example, I
fetch my entire database tree into memory (in my own tree structure, not a
tree view), then I just go through the whole thing, adding nodes to the tree
view. Its quicker than fetching one item from the database, adding it to
the tree, going back and fetching the next etc.

Also, consider categorisation. Are you sure you need a tree this large?

Why not just populate the root with the 1st and 2nd level nodes and then
when the user clicks to open a node, populate that node with the 3rd level
and so on.

Just some ideas ;)

"pmcguire" <an*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate it
in background and/or when the nodes are required by the user either
scrolling or performing some other action that would move the treeview
window to a particular "unloaded" node in the treeview.
Any advice on how to go about this? It seems I need a way of sensing a scroll event in the treeview control, but it does not appear that the
treeview control exposes this event.
Thanks for the help.

Nov 20 '05 #3
Yes, I am already employing that technique. The problem is that there are a lot of top-tier nodes. I anticipate that the next suggestion is to somehow reduce the number of top-tier nodes. I have already reduced them as much as possible (given client requirements)

So, assuming that I want to do what I said I want to do, how do I do it? :-)
Nov 20 '05 #4
Yes but how many are there? (approximately). I assume you also only need to
load the tree once.

"pmcguire" <an*******@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
Yes, I am already employing that technique. The problem is that there are a lot of top-tier nodes. I anticipate that the next suggestion is to
somehow reduce the number of top-tier nodes. I have already reduced them as
much as possible (given client requirements).
So, assuming that I want to do what I said I want to do, how do I do it?

:-)
Nov 20 '05 #5

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

Similar topics

3
by: sho_nuff | last post by:
Question here: I have been trying to find a way to add existing nested nodes to a tree that already has nodes in it: So, my tree looks like this: -com -foo -goo
4
by: Chuck Bowling | last post by:
I have a serialized TreeNodeCollection that I want to initialize a TreeView with. Is there a simple assignment I can use for this or do I have to iterate thru the collection and add individual...
4
by: JoKur | last post by:
I'm currently using a context menu to allow the user to add, rename and delete nodes in a treeview control. When a node is added we give it a bogus name ("NewNode") and invoke the add method. We...
1
by: garyusenet | last post by:
Hi All, I'm eagerly anticipating what you have to say on something that's stumped me over the weekend. I'm writing a small application which utilises a treeview control. I've figured out how to...
1
by: Turban | last post by:
When I attempt to run the following code: protected void NavigationTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e) { TreeNode tn1 = new TreeNode("node1","node1"); TreeNode tn2 =...
6
by: =?Utf-8?B?QnJhZA==?= | last post by:
VS,VB 2005 I have a treeview which i load data into in the forms load event Adding Nodes and Children to the parent nodes works fine to add a parent:...
1
by: weird0 | last post by:
Here is the code that i have been using to add nodes dynamically, but I cant see any child nodes being displayed on the treeView... all i can see the root node "Network". I have been trying to...
6
by: SQACSharp | last post by:
I'm using the EnumChildWindows API with an EnumChildWndProc callback to populate the treeview. The output will be something similar to spy+ + How can I specify the parent when adding a new node...
1
by: Bart Steur | last post by:
Hi As a VB6 user I'm unfamiliar with the Treeview control of VB2005. I read it was changed but I have a hard time finding the right help/samples for my problem. In VB6 you had 1 collection,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.