当前位置 : 主页 > 编程语言 > delphi >

delphi – VirtualTreeView:检查节点是否可见

来源:互联网 收集:自由互联 发布时间:2021-06-23
如何使用VirtualTreeView组件检查节点是否可见(在屏幕上)?像这样的东西: if not Grid.NodeVisible (Node) then Grid.ScrollIntoView (Node, True); 如果节点不可见,则该节点应居中,但如果节点可见则保持在
如何使用VirtualTreeView组件检查节点是否可见(在屏幕上)?像这样的东西:

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

如果节点不可见,则该节点应居中,但如果节点可见则保持在该位置.

请注意,我不是在谈论节点的可见标志,而是关于屏幕上的可见性.
在我的例子中,IsVisible属性总是返回True.

我认为最接近的是GetDisplayRect()方法:

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.

如果节点“可见但不可见”,则不确定它返回的内容 – 您可能必须编写辅助函数,该函数检查VT的客户端矩形内的返回rect …

网友评论