«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

How to check if a TTreeView is fully expanded or collapsed

   
function IsTreeviewFullyExpanded(tv: TTreeview): Boolean;
var
  node: TTreenode;
begin
  Assert(Assigned(tv));
  if tv.items.count > 0 then
  begin
    node := tv.Items[0];
    Result := true;
    while Result and Assigned(node) do
    begin
      Result := node.Expanded or not node.HasChildren;
      node := node.GetNext;
    end;
  end
  else
    Result := false
end;

function IsTreeviewFullyCollapsed(tv: TTreeview): Boolean;
var
  node: TTreenode;
begin
  Assert(Assigned(tv));
  if tv.items.count > 0 then
  begin
    node := tv.Items[0];
    Result := true;
    while Result and Assigned(node) do
    begin
      Result := not (node.Expanded and node.HasChildren);
      node := node.GetNext;
    end;
  end
  else
    Result := false
end;
Original resource: The Delphi Pool
Author: Peter Below
Added: 2009-08-24
Last updated: 2009-08-24

« Return to contents »