473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

treeview with lots of nodes (chapter 2)

OK. My treeview still has a tier with too many nodes (ca. 20,000), but it's the best I can do. Now it only populates that tier in the (unlikely) event that a user tries to expand that tier's parent node.

To prevent the user from thinking its machine has locked up, I want to provide it with a progress bar to show that the nodes are being loaded. For generality, I created a form with a Label and a ProgressBar on it, but it doesn't really work like I want. I suspect I need to multithread, but I don't know how to do this, so...

Anyway, here's the code, any advice?

Private Sub LoadNonItemedFacilities(ByRef aNode As TreeViewEx.vb.TreeViewEx.TreeNode)
Dim drarray() As Data.DataRow
Dim dr As Data.DataRow
Dim filter As String = "Items Is Null"
Dim sort As String = "FDEPFacilityID"
Dim fac As Facility
Dim ndNew As TreeViewEx.vb.TreeViewEx.TreeNode
Dim cnt As Integer = 1
Dim recCount As Integer
Dim prg As frmProgress

drarray = dsFacilityInformation.tblFacility.Select(filter, sort, DataViewRowState.CurrentRows)
prg = New frmProgress
prg.Visible = True
prg.Text = "Populating Tree"
recCount = drarray.Length
prg.MaxValue = recCount
If Not drarray.Length = 0 Then
aNode.Nodes.Clear()
For Each dr In drarray
prg.Value = 100 * (cnt / recCount)
fac = New Facility(dr)
ndNew = New TreeViewEx.vb.TreeViewEx.TreeNode(fac.ToString)
ndNew.NodeKey = "fac" & fac.FDEPFacilityID
aNode.Nodes.Add(ndNew)
cnt = cnt + 1
Next
ndNew = New TreeViewEx.vb.TreeViewEx.TreeNode("<New>")
ndNew.NodeKey = "fac<New>"
aNode.Nodes.Add(ndNew)
End If
_nonItemedFacilitiesLoaded = True
prg.Close()

End Sub

Nov 20 '05 #1
1 1207
"pmcguire" <an*******@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
OK. My treeview still has a tier with too many nodes (ca. 20,000), but it's the best I can do. Now it only populates that tier in the (unlikely)
event that a user tries to expand that tier's parent node.
To prevent the user from thinking its machine has locked up, I want to provide it with a progress bar to show that the nodes are being loaded. For
generality, I created a form with a Label and a ProgressBar on it, but it
doesn't really work like I want. I suspect I need to multithread, but I
don't know how to do this, so...
Anyway, here's the code, any advice?


Take a look at the ThreadPool documentation. It allows you to spawn a new
thread and pass it some data _very_ easily. So you code will look something
like this:

'// going from memory here,
'// so actual code may be slightly different
ThreadPool.QueNewWorkerThread(AddressOf LoadNonItemedFacilities,
THE_NODE_TO_LOAD)

and you will need to modify the signature of LoadNonItemedFacilities():

FROM:
Private Sub LoadNonItemedFacilities(ByRef aNode As
TreeViewEx.vb.TreeViewEx.TreeNode)

TO:
Private Sub LoadNonItemedFacilities(ByRef aNode As Object)
Dim targetNode as TreeViewEx.vb.TreeViewEx.TreeNode
targetNode = DirectCast(aNode, TreeViewEx.vb.TreeViewEx.TreeNode)
...
HTH,
Jeremy

Nov 20 '05 #2

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

Similar topics

4
by: alanrn | last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection (inherited from CollectionBase). The order of the nodes in the TreeView is strictly tied to the order in which they...
4
by: hzgt9b | last post by:
Using VS.NET 2003, VB: I have a TreeView object with lots of nodes. The treeview is docked on the left side of my main from in a splitter. I want to set the splitter's initial width to allow all...
5
by: Mark Goldin | last post by:
Anybody can shart some working samples of using that control on Windows form? Thanks
3
by: Jan Wrage | last post by:
Hi! I would like to implement a treeview in my existing application. It should show my entire Active-Directory structure, i.e. all Groups, Containers and OUs. Could somebody help me with...
14
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
2
by: C. A. Kelly | last post by:
I have seen lots of posts for populating a treeview from a XML file but haven't been able to find/figure out how to go from a treeview to XML.
5
by: Paul | last post by:
Hi, I am a self taught VBA programmer, and I'm trying to learn VB2005 Express (The price was right). I like the look of the treeview control, and I'd like to use it as a menu system for my users,...
1
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
0
by: Tor Inge Rislaa | last post by:
Controlling TreeView Expand/Collapse With a TreeView bound to an XML file as below I want to obtain the functionality where Chapter 2 and 3 are forced to collapse when Chapter 1 is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.