Posted 5 November 2017, 5:47 pm EST
In a simple app, scrolling the treeview or resizing the from slows to a crawl based on the number of items in the treeview. The below app, which contains 3,000 nodes (not a huge amount) illustrates the problem. This is true with bound and unbound examples.
Make a simple 1 form solution, add a c1Treeview named ‘tv’ (set dock to fill) then paste the code below.
Imports System.ComponentModel
Public Class Form1
Private things As New BindingList(Of classThing)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
tv.ScrollBars = ScrollBars.Both
For i = 1 To 1000
Dim thing As classThing
thing = New classThing(“First thing”, “1”)
things.Add(thing)
Dim child = New classThing(“Child thing”, “2”)
thing.add(child)
Dim grandchild = New classThing(“Grandchild thing”, “3”)
child.add(grandchild)
Next
tv.DataMember = “\children\children”
tv.DataSource = things
tv.ExpandAll()
End Sub
End Class
Public Class classThing
Public Property title As String
Public Property id As String
Public Property children As BindingList(Of classThing)
Public Sub New(_title As String, _id As String)
title = _title
id = _id
End Sub
Public Overrides Function tostring() As String
Return title
End Function
Public Sub add(_thing As classThing)
If children Is Nothing Then children = New BindingList(Of classThing)
children.Add(_thing)
End Sub
End Class