{字面意思如上,为了节省资源,生成TreeView时可以只载入第一层数据,但是每个Node的HasChildren设置为True(这样前面就有+)号,然后在Expanding事件中这样处理: }procedure TfrmCodes.TreeView1Expanding(Sender: TObject; Node: TTreeNode; var AllowExpansion: Boolean); begin inherited; with Node do begin if (Count < 1) then LoadChildren(Node); HasChildren := Count > 0; AllowExpansion := HasChildren; end; end;
OnExpanded 节点展开后....
}procedure TfrmCodes.TreeView1Expanding(Sender: TObject; Node: TTreeNode;
var AllowExpansion: Boolean);
begin
inherited; with Node do
begin
if (Count < 1) then LoadChildren(Node);
HasChildren := Count > 0;
AllowExpansion := HasChildren;
end;
end;
expanding
adj.扩展的,扩充的呵呵