Reputation: 16620
How to check if a node is visible (on screen) with VirtualTreeView component? Something like this:
if not Grid.NodeVisible (Node) then
Grid.ScrollIntoView (Node, True);
The node should be centered if it was not visible, but remain where it is if it was visible.
Note that I am not talking about the node's visible flag, but about visility on the screen.
The IsVisible
property always returns True
in my case.
Upvotes: 4
Views: 2422
Reputation: 618
The IsVisible property only returns if the nodes has been hidden or not as you found. The only way to find if a node is on screen is to use the GetDisplayRect as ain suggested and then test it against the client rectangle of the tree view.
However, if I understand what you are trying to do correctly, the toCenterScrollIntoView option in the SelectionOption of the VirtualTreeView will give you the behavior you want without having to test if the node is in the visible area or not.
ie(C++):
TreeView->TreeOptions->SelectionOptions =
TreeView->TreeOptions->SelectionOptions << toCenterScrollIntoView ;
...
ScrollIntoView(Node);
Upvotes: 0
Reputation: 22769
I think the closest thing there is is the GetDisplayRect()
method:
Determines the client coordinates the given node covers, depending on scrolling, expand state etc. If the given node cannot be found (because one of its parents is collapsed or it is invisible) then an empty rectangle is returned.
Not sure what it returns in case the node is "visible but out of view" - you might have to write helper function which checks is the returned rect inside VT's client rectangle...
Upvotes: 4