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 .