2

In our application I'm moving from a TStringGrid to TVirtualStringTree component. A lot of data is being displayed (max. 50000 lines and 5 columns). One column contains on or more lines of text. I managed to implement multiline functionality using 'DrawCell' in the stringgrid with optimal performance: instant redraw of all lines (on resize) and scrolling without hitches (I have a list of row heights in memory, which will be updated when redraw is needed).

Transferring this multiline functionality to the VirtualStringTree is not as performant as the stringgrid alternative. I tried numerous implementations but have not yet succeeded. This is easily reproducable in the Demo application of the VirtualStringTree installation package:

  1. In the 'MultilineDemo' form, set the 'rootNodeCount' of the VirtualStringTree to 10.000.
  2. When running the demo, select 'Automatically adjust node height to node text.'

Initial redraw/repaint will take a while using lots of CPU. Ater each resize, jumping to top/bottom causes the same phenomenon, or even causing a 'stack overflow' exception (but that's another issue ...). The 'OnMeasureItem' method is called way too much, the way I see it (even on 'MouseMove' events).

Has anyone had this problem and managed to find a solution?

user729103
  • 631
  • 2
  • 10
  • 24
  • I haven't checked how that demo is implemented (yet), but if it uses measurement events, then you can try a different way. You said that you have a collection of row heights prepared, so you might try to set the node heights statically by using `NodeHeight` property when you'll be filling the tree. However, I wouldn't expect a notable difference (assuming they are not doing anything expensive in that demo). – TLama May 13 '15 at 13:52
  • Thank you for your suggestion @TLama. I already tried using my own collection of heights but haven't quite managed to produce a fully working version. Redraw timing of the nodes is a bit different than at the stringgrid. – user729103 May 13 '15 at 14:35

1 Answers1

2

This is easily reproducable in the Demo application of the VirtualStringTree installation package

At least this performance issue is easily solved by wrapping the call to ReinitNode() in a BeginUpdate() and EndUpdate():

 MLTree.BeginUpdate();
  try
    MLTree.ReinitNode(nil, True);
  finally
    MLTree.EndUpdate();
  end;

I slightly reworked the sample project and the Virtual Treeview today, the sample project works much smoother now. Just try the latest source code from GitHub.

Joachim Marder
  • 782
  • 5
  • 12