G
Guest
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
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