treeView NODE DELETE

 function DelTreeNode( Node: TTreeNode ): Boolean;
var Parent: TTreeNode;
    childNode: TTreeNode;
begin
  Parent := nil;
  childNode := nil;
  if Assigned(Node) then
  begin
    if Assigned(Node.Parent) then
    begin
      //保存父结点
      Parent := Node.Parent;
    end;

    if( Node.HasChildren ) then
    begin
      childNode := Node.GetLastChild;
      while( Assigned( childNode ) ) do
      begin
        if ( childNode.HasChildren ) then
          DelTreeNode(childNode)
        else childNode.Delete;
        childNode := Node.GetLastChild;
      end;
      if( not ( Node.HasChildren ) )then
         Node.Delete;
    end else
    begin
      Node.Delete;
    end;
  end;
end;

你可能感兴趣的:(DELPHI,方面的技术资料)