Today I need to know how many root nodes (I mean without parent node) has my tree. I wrote this:
Delphi-Quellcode:
function CountTreeNodes(ATree: TTreeView; ALevel: Word): Integer;
var
I: integer;
begin
Result := 0;
for I := 0 to ATree.Items.Count - 1 do
begin
if ALevel = ATree.Items[I].Level then
Inc(Result)
;
end;
end;
Count := CountTreeNodes(Tree, 0);
This is working, but is quite lame IMO - function will be slow and sloow and slooow if many nodes on tree. Is possible to do it in pro mode?