【发布时间】:2019-03-07 10:50:11
【问题描述】:
我需要在TVirtualStringTree 中显示一个长 db 表(例如 50000 条记录)。为了降低查询执行时间,我将记录数限制为仅实际显示在树中的记录数。处理OnGetText的代码sn-p如下。问题是 VisibleCount 返回 50000 而不是 20-30 这破坏了这种方法。有没有办法正确地做到这一点?
procedure TContactsFrame.vstContactsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
begin
if vstContacts.GetNodeLevel(Node) = 0 then
CellText := 'Group'
else if vstContacts.GetNodeLevel(Node) = 1 then
begin
if Contacts[Node.Index].Index = -1 then
begin
// getting DB table values of visible records only
GetContacts(Node.Index + 1, Node.Index + 1 + vstContacts.VisibleCount, Contacts);
end;
CellText := Contacts[Node.Index].Name;
end;
end;
【问题讨论】: