How to refresh Vertical scrollbar in VirtualStringTree?
how to refresh the scrollbar of VirtualStringTree
if each nodeheight 开发者_如何学Pythonwas changed into different Height. coz, the scroll are still in the same state causing other node cannot be viewed when scrolled.
toVariableNodeHeight
option will not work? any other idea?
Something tells me that when you say "each NodeHeight was changed," you really mean to say that you assigned new values directly to the NodeHeight
field of each of the node records. First of all, don't do that. If you must assign heights to nodes, assign them through the tree's NodeHeight
property. That is, instead of this:
{*} Node.NodeHeight := x;
Do this:
Tree.NodeHeight[Node] := x;
That will automatically adjust the cached heights of all the node's ancestors, which is what determines the scroll-bar range.
Better yet, don't assign heights to nodes at all. Instead, handle the tree's OnMeasureItem
event, where the tree asks you how tall each node is. That event is fired when you have the toVariableNodeHeight
option set.
If you really insist on skipping the tree's node-height management, then you need to make sure you handle all the necessary tasks yourself. That includes updating not only the NodeHeight
field but also the TotalHeight
field of the node, its parent, its grandparent, and so on until you've set the total height of the hidden root node. See TBaseVirtualTree.AdjustTotalHeight
for details. It has private visibility, so you can't call it yourself.
OnMeasureItem
will only get called once for a node. If you need it to be called again because the node's contents have changed and you need the tree to re-measure the height, then call ReinitNode
. If you're using TCustomVirtualStringTree
, you can also call InvalidateNode
.
精彩评论