说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

我想用treeview,它和outline有什么区别?谁有treeview的例子?

编辑:说三道四文库 发布时间:2018-02-24 06:24
HTML文档下载 WORD文档下载 PDF文档下载
我想用treeview,它和outline有什么区别?谁有treeview的例子?谢谢!
分已用的差不多拉!请各位原谅!
var
  node: TTreenode;
begin
  node := treeview1.add(nil,'父1');
  treeview1.addChild(node,'子1');
  node := treeview2.add(nil,'父2');
  node := treeview3.addChild(node,'子2');
  treeview3.addChild(node,'子3');
end;
procedure DirToTreeView(ATreeView: TTreeView; ADirectory: string;
  ARoot: TTreeNode; AIncludeFiles: Boolean);
var
  SearchRec : TSearchRec;
  ItemTemp : TTreeNode;
begin
  with ATreeView.Items do
  try
    BeginUpdate;
    if ADirectory[Length(ADirectory)] <> '\' then
      ADirectory := ADirectory +'\';
    if FindFirst(ADirectory + '*.*', faDirectory, SearchRec) = 0 then
    begin
      repeat
      if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] <> '.') then
      begin
        if (SearchRec.Attr and faDirectory > 0) then
          ARoot := AddChild(ARoot, SearchRec.Name);
        ItemTemp := ARoot.Parent;
        DirToTreeView(ATreeView, ADirectory + SearchRec.Name, ARoot, AIncludeFiles);
        ARoot := ItemTemp;
      end
      else if AIncludeFiles then
        if SearchRec.Name[1] <> '.' then
          AddChild(ARoot, SearchRec.Name);
      until FindNext(SearchRec) <> 0;
      FindClose(SearchRec);
    end;
  finally
    EndUpdate;
  end;
end;
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘