procedure TFormCustomerPage.cxTreeView1Expanded(Sender: TObject;
  Node: TTreeNode);
var
  ANode: TTreeNode;
begin
  inherited;
  ANode := Node.Parent;
  if ANode = nil then
    ANode := TTreeView(Sender).Items[0];
  if ANode <> nil then
  begin
    TTreeView(Sender).Items.BeginUpdate;
    try
      if ANode = Node.Parent then
           ANode := ANode.getFirstChild;
      while ANode <> nil do
      begin
        if ANode <> Node then
          ANode.Collapse(True);
        ANode := ANode.getNextSibling;
      end;
    finally
      TTreeView(Sender).Items.EndUpdate;
    end;
  end;
end;
posted on 2011-05-18 22:17  fyen  阅读(2035)  评论(0编辑  收藏  举报