Listbox expands slow on Windows only

I have an hierarchical listbox that gets populated using a hierarchical, in memory, datastructure (a.k.a treenode)
when I expand a row, each parent-treenode (attached to the rowtag) show its childnodes.

On my Mac this is blazing fast but on a Windows PC the same listbox needs multiple seconds for even a few childrows to show.
A few dozen rows can take a whole minute before they appear.

any ideas?

I use Einhugurs TreeView on macOS and Windows and see no such issues. Maybe it’s worth a try?
http://www.einhugur.com/Html/TreeView/index.html

not to be flippant… but something is wrong in your code.

My treeview control has no issue with handling hundreds of child nodes

http://www.rdS.com/treeview/

But it is the exact same code for both platforms and on my mac it is super fast

show us the money… er… “the code”

if (row >= 0) and (row < sender.ListCount) then
  
  if sender.RowIsFolder(row) then
    
    dim expandedNode as JVtreeNode = sender.RowTag(row)
    For each childNode as JVtreeNode in expandedNode.children
      displayNode(childNode)
    next
    
    // Remember this row as being expanded
    dim pathString as String = pathForRow(row)
    dim index as Integer = expandedNodes.IndexOf(pathString)
    
    if index < 0 then
      expandedNodes.append(pathString)
    end if
    
  end if
  
end if[/code]

then in displayNode(node as JVTreeNode)

[code]if node <> nil then
  
  dim numberOfFields as Integer
  
  if node.representedObject isa Dictionary then
    dim representedObject as Dictionary = node.representedObject
    numberOfFields = representedObject.keys.ubound+1
  elseif node.representedObject isa DatabaseRecord then
    dim representedObject as DatabaseRecord = node.representedObject
    numberOfFields = representedObject.FieldCount
  end if
  // Adjust the number of columns if needed
  treeView.ColumnCount = Max(treeView.ColumnCount, numberOfFields)
  
  
  // Proces the record
  dim itsAnExpandableNode as Boolean =(treeView.treeViewDataSource.isItemExpandable(node))
  if   itsAnExpandableNode then // Add an empty Folder or an empty row
    treeView.AddFolder("")
  else
    treeView.AddRow()
  end if
  dim newRowNumber as Integer = treeView.LastIndex
  treeview.RowTag(newRowNumber) = node
  
  
  // Proces the individual fields
  
  for  fieldNumber as Integer = 0 to numberOfFields-1
    
    dim fieldName as Variant
    dim fieldValue as  Variant
    if node.representedObject isa Dictionary then
      dim representedObject as Dictionary = node.representedObject
      fieldName = representedObject.key(fieldNumber)
      fieldValue = representedObject.value(fieldName)
    elseif node.representedObject isa DatabaseRecord then
      dim representedObject as DatabaseRecord = node.representedObject
      fieldName = representedObject.FieldName(fieldNumber)
      fieldValue = representedObject.Column(fieldName.StringValue)
    end if
    
    // Prepare the field in the backend
    dim tagValue as Pair = fieldName: fieldValue
    treeView.celltag(newRowNumber, fieldNumber) = tagValue
    
    // Make the cell redraw itself
    treeView.InvalidateCell(newRowNumber, fieldNumber)
    
  next
  
end  if

so it looks like you are NOT having an issue with an Xojo Listbox… but rather some 3rd party treeview control.(JVTree?)… in which case it might be best to contact the author for support

JVTree is just a my own subclass of listbox that has the hierarchical-property set to True.
Nothing special about it.

[quote=384300:@Jan Verrept]JVTree is just a my own subclass of listbox that has the hierarchical-property set to True.
Nothing special about it.[/quote]
ok… well can’t help… good luck

Hi Jan,

I do not read it (so I do not if it will help you), but you may rad (if not already):

http://developer.xojo.com/userguide/code-profiler

  • What release are you seeing this slow behavior on?
  • Do you see the slow behavior in the IDE only or also in compiled binaries?

Are the binaries generated on macOS or on Windows ?

How many childrows do you typically show?

Use the profiler on your code to see which part of the code is doing so poorly. Also an example with data so that we can have a look would be good.

Dont do that here.
Do it once at the start, before you begin to fill.
Or have enough to begin with and delete unused ones once at the end if you must.

dim representedObject as Dictionary = node.representedObject

No need to do that, node is already a dictionary.
Just use node there.

The whole code is very convoluted.
The use of ‘sender’ suggests to me that this is code originally written in Delphi and converted?

I’ve subclassed the listbox control and build my own with data initially stored into memory and show only what you need plus a little bit more on top and bottom to have smooth scrolling. And this works up to 200 k rows , even on Windows but with 2017R3. With the speed of 2018R1 on Windows you can’t make anything behave satisfactory at all.

Didn’t know about the profiler. Great tool!

Turns out it was some unrelated code that was the culprit ,
it showed a tooltip in a mousemove-event
Removed the tooltip and all is fine again.

Thank you so much

[quote=384287:@Dave S]

http://www.rdS.com/treeview/[/quote]
“It has not been tested with Yosemite, El Capitan, Windows 8 or Windows 10”

Time to update the website, Dave? :wink:

[quote=384516:@Julia Truchsess]“It has not been tested with Yosemite, El Capitan, Windows 8 or Windows 10”

Time to update the website, Dave? ;)[/quote]
yeah I guess so… since I know there are users that are using it successfully on the latest OS versions