首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无限滚动VirtualTreeView

无限滚动VirtualTreeView
EN

Stack Overflow用户
提问于 2015-09-03 13:55:41
回答 1查看 660关注 0票数 4

是否有一种使用虚拟树视图实现无限滚动的方法?

我希望一次加载一组数据库记录,并在用户向下滚动时将它们添加到虚拟树视图中。但我不确定如何触发新行的添加。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-03 14:40:16

您可以处理OnScroll事件,并检查滚动条是否以这种方式到达末尾:

代码语言:javascript
复制
type
  // this interposer class is used to publish the RangeY property
  TVirtualStringTree = class(VirtualTrees.TVirtualStringTree)
  public
    property RangeY;
  end;

procedure TForm1.VirtualStringTreeScroll(Sender: TBaseVirtualTree; DeltaX,
  DeltaY: Integer);
var
  Tree: TVirtualStringTree;
begin
  // if the vertical scroll occurred, then...
  if DeltaY <> 0 then
  begin
    // just a helper variable
    Tree := TVirtualStringTree(Sender);
    // if the client height without the top offset equals, or exceeds (actually, it should
    // never exceed; just for sure) the virtual tree height, then we reached the bottom of
    // the tree, so...
    if Tree.ClientHeight - Tree.OffsetY >= Integer(Tree.RangeY) then
    begin
      // the scrollbar reached the end of the tree; now fetch your data and add some nodes
      // (ideally as a thread task showing some fancy animation; the following is just for
      // example)
      ShowMessage('Fetch your data...');
      Tree.RootNodeCount := Tree.RootNodeCount + 50;
    end;
  end;
end;
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32377678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档