I've had the same problem working with TVirtualDrawTree's. You have to make sure that node heights are computed before the tree actually scrolls.
This is what I do:
1.- Add this code to the OnInitNode event so that the tree knows that the height of the new node must be computed:
Node.States := node.States + [vsMultiline] - [vsHeightMeasured];
2.- In the OnMeasureItem, if you can't compute the height (e.g. node not initialized yet), make sure you tell the tree to repeat the call when needed:
In the OnMeasureItem event handler:
If (Node = Nil) Or (Node = tree.RootNode) Then Begin
Exclude(Node.States, vsHeightMeasured);
Exit;
End;
NodeData := tree.GetNodeData(Node);
If (NodeData = Nil) Or (NodeData^.XMLNode = Nil) Then Begin
Exclude(Node.States, vsHeightMeasured);
Exit;
End;
Try
// Code to measure node height here.
Except
Exclude(Node.States, vsHeightMeasured);
End;
I hope it helps you.