Rather than load all my data into the treeview I am loading when a
level-1node gets expanded (for the first time).
To set up the code below, I've added a single child node for each
level-1node, just so that I can get the "+" and the capability to
expand.
So the first time I click on any level-1 node, it loads 30 child nodes.
The problem is how slow this is. To me it should be almost
instantaneous. It takes 2-3 seconds, which doesn't sound like much,
but believe me, it's irritating. The scroll bar rolls down the screen.
Once the nodes are populated, expanding and collapsing the parent node
is suitably quick.
Any ideas on at least making this appear quicker?
----------------
Private Sub myTreeView_AfterExpand(ByVal sender As Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles myTreeView.AfterExpand
Dim classNode As TreeNode
Dim testCtr As Integer
If e.Node.Nodes.Count = 1 Then
If e.Node.Text = e.Node.Nodes(0).Text Then
e.Node.Nodes.Clear()
For testCtr = 1 To 50
classNode = e.Node.Nodes.Add(testCtr.ToString)
Next
End If
End If
End Sub
Robinson - 29 Nov 2006 21:00 GMT
Bracket all adds with this:
myTreeView.BeginUpdate ()
.............
.............
myTreeView.EndUpdate ()
cowznofsky - 30 Nov 2006 15:20 GMT
Ah, much better. Thanks!
> Bracket all adds with this:
>
[quoted text clipped - 4 lines]
>
> myTreeView.EndUpdate ()
tommaso.gastaldi@uniroma1.it - 29 Nov 2006 23:06 GMT
cowznofsky ha scritto:
> Rather than load all my data into the treeview I am loading when a
> level-1node gets expanded (for the first time).
[quoted text clipped - 5 lines]
>
> The problem is how slow this is.
See if this improves (vb2005):
Private Sub myTreeView_AfterExpand(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.TreeViewEventArgs) _
Handles MyTreeView.AfterExpand
Dim testCtr As Integer
Dim SubNodes As New List(Of TreeNode)
If e.Node.Nodes.Count = 1 Then
If e.Node.Text = e.Node.Nodes(0).Text Then
e.Node.Nodes.Clear()
For testCtr = 1 To 50
SubNodes.Add(New TreeNode(testCtr.ToString))
Next
e.Node.Nodes.AddRange(SubNodes.ToArray)
End If
End If
End Sub