Link to home
Start Free TrialLog in
Avatar of LMuadDIb
LMuadDIbFlag for United States of America

asked on

count a treeview root items

hey all,
anyone have a function that can count the root items in a treeview?
not the total item count, I dont want to count the children....
Avatar of DavidBirch2dotCom
DavidBirch2dotCom

You might be interested in a treeview which is a huge amount better than the delphi default one Virtual treeview from www.delphi-gems.com - it has a rootnodecount property and has many more options... its well worthwhile if you are going to be doing anything serious with a treeview

David

ASKER CERTIFIED SOLUTION
Avatar of DavidBirch2dotCom
DavidBirch2dotCom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kretzschmar
another possibility (just from head, not tested)

function countChilds(ATree : TTreeView;ANode : TTreeNode) : Integer;
var
  CNode : TTreeNode;
begin
  result := 0;
  if ANode = Nil then
    CNode := ATree.Items.GetFirstNode
  else
    cNode := ANode.GetFirstChild;
  if assigned(CNode) then
  begin
    while assigned(CNode) do
    begin
      result := result +1;
      cNode := cNode.GetNextSibling;
    end;
  end;
end;


meikl ;-)
Thanks for the points :)

I beat the mighty kretzschmar  ;-p) he he ;)

David
:-))
i posted my suggestion already after you got the grade, david,
so you was never in danger :-))

btw. i'm not mighty, i'm just a simple coder

meikl ;-)