How to reliably scroll Virtual TreeView to the end?

TVirtualStringTree object with a height-adjustable node, how to reliably scroll a Virtual TreeView to the bottom (i.e. scrollbar is approaching)?

I tried to call tree1.FullExpand, then tree1.ScrollIntoView.(tree1.GetLast), but it does not work.

Thanks in advance.

+5
source share
4 answers

ScrollIntoView works great for me. You can also trytree1.FocusedNode := tree1.GetLast;

Are you setting a custom node height in the OnMeasureItem event? If this does not work, try setting the DefaultNodeHeight tree to a larger value, and in the OnMeasureItem event, change it to a lower one. I noticed that the tree more accurately calculates the length of the scroll bar.

+5

:

SendMessage(VST.Handle, WM_VSCROLL, SB_BOTTOM, 0);
PostMessage(VST.Handle, WM_VSCROLL, SB_BOTTOM, 0);
+4

:

tree1.TopNode := tree1.GetLast
+1

TVirtualDrawTree. , node .

, :

1.- OnInitNode, , node :

Node.States := node.States + [vsMultiline] - [vsHeightMeasured];

2.- OnMeasureItem, (, node ), , , : OnMeasureItem:

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;

, .

+1

All Articles