473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2302
* "=?Utf-8?B?cG1jZ3VpcmU =?=" <an*******@disc ussions.microso ft.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*******@disc ussions.microso ft.com> wrote in message
news:95******** *************** ***********@mic rosoft.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*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** ***********@mic rosoft.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
2894
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
13144
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 Nodes?
4
24239
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 would then to then select the newly added node and rename it but can't figure out how to select the node via code. How do you select a node from code when you don't know the index? -- Thanks
1
2717
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 programatically add nodes to it, but everytime the program is exited the treeview control resets itself. I looked for a save method or something similair but there doesn't seem to be one. I have found the copyto method, and figured out how to...
1
2878
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 = new TreeNode("node2", "node2"); TreeNode newNode = new TreeNode("add me to both nodes", "add me to both nodes"); e.Node.ChildNodes.Add(tn1); e.Node.ChildNodes.Add(tn2);
6
2783
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: Me.tvGroups.Nodes.Add(GroupDataRow(0)("MenuGroupID").ToString, GroupDataRow(0)("GroupLabel")) to add a child to a Parent:
1
15065
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 develop a modelling soft. as an educational project. // event fires when shape is added to visio control if (vsoMaster.Name == "Ellipse") {
6
2506
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 ?? When adding a new node is there any way to get an handle or something else to be able add the childs to the correct parent ? Thanks!
1
1902
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, and adding a node was quite simple. Just specify the nodes key and position relative to the key where you want to add your new node. In VB2005 you can't do that anymore. I looking for a sample or help how this
0
8421
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
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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
8742
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...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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
7354
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
5643
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();...
1
2743
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.