VirtualTreeView: check if node is displayed

How to check if a node is displayed (on the screen) using the VirtualTreeView component? Something like that:

if not Grid.NodeVisible (Node) then Grid.ScrollIntoView (Node, True); 

the node should be centered if it was not visible, but stayed where it was if it was visible.

Note that I'm not talking about the node sign, but about visibility on the screen. The IsVisible property always returns True in my case.

+4
source share
2 answers

I think the closest is the GetDisplayRect() method:

Determines that the client coordinates node cover data, depending on scrolling, state expansion, etc. If the given node cannot be found (because one of its parents has crashed or it is invisible), then the empty rectangle is returned.

Not sure if it returns if the node is "visible, but out of sight" - you may need to write a helper function, the check of which is the returned rectangle inside the VT client rectangle ...

+3
source

The IsVisible property returns only if the nodes were hidden or not, as you found. The only way to find if the node is on the screen is to use GetDisplayRect as suggested, and then check it for the client tree view rectangle.

However, if I understand what you're trying to do correctly, the toCenterScrollIntoView parameter in SelectionOption VirtualTreeView will give you the behavior you need without checking if the node is in the visible area or not.

t (C ++):

 TreeView->TreeOptions->SelectionOptions = TreeView->TreeOptions->SelectionOptions << toCenterScrollIntoView ; ... ScrollIntoView(Node); 
0
source

Source: https://habr.com/ru/post/1402386/


All Articles