Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Expand and Collaps TreeNodes

Hello everyone

I would like to close the other open nodes in the same level in an ElXTree tree when expanding a node.
How can I implement this? 

I can't find any information about the OnItemExpand or OnItemExpanding events in the HelpFiles or MegaDemos
Best regards gerd

Comments

  • 1 Comment sorted by Votes Date Added
  • There are no special built-in utility for that, so you just have to iterate items and collapse all siblinks manually. Use OnItemExpand event for that:

    procedure TForm20.ElXTree1ItemExpand(Sender: TObject; Item: TElXTreeItem);
    begin
      ElXTree1.Items.BeginUpdate;
      try
        var itm := Item.GetFirstSibling;
        while itm <> nil do
        begin
          if itm <> Item then
            itm.Collapse(True);
          itm := itm.GetNextSibling;
        end;
      finally
        ElXTree1.Items.EndUpdate;
      end
    end;
Sign In or Register to comment.