一个具有自定义节点高度的 TVirtualStringTree 对象,如何可靠地将 Virtual TreeView 滚动到底部(即滚动条到达底部)?
我尝试调用 tree1.FullExpand
然后 tree1.ScrollIntoView.(tree1.GetLast)
,但它不起作用。
提前感谢你。
一个具有自定义节点高度的 TVirtualStringTree 对象,如何可靠地将 Virtual TreeView 滚动到底部(即滚动条到达底部)?
我尝试调用 tree1.FullExpand
然后 tree1.ScrollIntoView.(tree1.GetLast)
,但它不起作用。
提前感谢你。
ScrollIntoView 对我来说效果很好。你也可以尝试使用 tree1.FocusedNode := tree1.GetLast;
你是否在 OnMeasureItem 事件中设置了自定义节点高度? 如果没有生效,尝试将树的 DefaultNodeHeight 设置为更大的值,并在 OnMeasureItem 事件中将其改为较低的值。我注意到这样树会更好地重新计算滚动条的长度。
试试这个:
SendMessage(VST.Handle, WM_VSCROLL, SB_BOTTOM, 0);
PostMessage(VST.Handle, WM_VSCROLL, SB_BOTTOM, 0);
2.- In the OnMeasureItem event, compute the height of the node using the information you have:
2. 在 OnMeasureItem 事件中,使用你拥有的信息计算节点的高度:
Node.States := node.States + [vsMultiline] - [vsHeightMeasured];
2.- 在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;
这个也应该可以工作:
tree1.TopNode := tree1.GetLast