Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi VirtualTreeString AddChild (https://www.delphipraxis.net/156686-virtualtreestring-addchild.html)

sdean 10. Dez 2010 21:30

Delphi-Version: 7

VirtualTreeString AddChild
 
Hi , i've this code to populate a Tree :
Delphi-Quellcode:
type
  PMyList = ^AList;
  AList = record
    FileName:String;
    Dir:String;
  end;

{
If there are many Files with same extension than
don't create a new Father for each , But rather gather
them under One Father :

EXE
 |_1.exe
 |_2.ex
 .....
NOT -------------- 
EXE
 |_1.exe
EXE
 |_2.exe
------------------
}
function FindRootNode(const ATvNodeText: String): TTreeNode;
var
  I: Integer;
begin
  Result := nil;
  for I := 0 to form1.tv.Items.Count - 1 do
    if form1.tv.Items[I].Level = 0 then
      if form1.tv.Items[I].Text = ATvNodeText then
      begin
        Result := form1.tv.Items[I];
        Break;
      end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,j:Integer;
ARecord1,ARecord2: PMyList ;
tvNode:TTreeNode;
begin
 for i:=MyFilesList.Count-1 downto 0 do   begin
 for j := (MyFilesList.Count -1) downto (i + 1) do

if PMyList(MyFilesList.Items[i])^.FileName=PMyList(MyFilesList.Items[j])^.FileName then begin
 ARecord1:= MyFilesList.Items[i];
 ARecord2:= MyFilesList.Items[j];
 MyFilesList.Remove(ARecord1);


tvNode:= FindRootNode(ExtractFileExt(ARecord1^.FileName));
   if tvNode= nil then
tvNode:=tv.Items.Add(nil,ExtractFileExt(ARecord^.FileName));
tv.Items.AddChild(tvNode,ARecord1^.FileName);
tv.Items.AddChild(tvNode,ARecord2^.FileName);
end;
end;
end;
My Question is how to replace TreeView with VirtualTreeString with same tv addChild routine .

many thanks .


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:37 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz