来源于研究分享,有能起到帮助的就默默的感谢下他吧哈!
// 删除TreeList已选择的节点 procedure TreeListDeleteChecked(ATreeList: TcxCustomTreeList); overload; procedure TreeListDeleteChecked(ANode: TcxTreeListNode); overload; procedure TreeListDeleteChecked(ATreeList: TcxCustomTreeList); var ANode, ARoot: TcxTreeListNode; i: Integer; begin if ATreeList = nil then exit; ANode := ATreeList.FocusedNode; if ANode = nil then exit; if (ANode.CheckState in [cbsChecked]) then begin ANode := ATreeList.FocusedNode.getPrevSibling; end; ATreeList.BeginUpdate; try for i := ATreeList.Count - 1 downto 0 do begin ARoot := ATreeList.Items[i]; if ARoot.CheckGroupType = ncgCheckGroup then begin if (ARoot.CheckState in [cbsChecked]) then begin ARoot.Delete; end else if (ARoot.CheckState in [cbsGrayed]) then begin TreeListDeleteChecked(ARoot); // 调用递归删除节点 end; end; end; finally if ANode <> nil then ATreeList.FocusedNode := ANode; ATreeList.EndUpdate; end; end; procedure TreeListDeleteChecked(ANode: TcxTreeListNode); var i: Integer; tmpNode: TcxTreeListNode; begin if ANode = nil then exit; for i := ANode.Count - 1 downto 0 do begin tmpNode := ANode.Items[i]; while tmpNode <> nil do begin if tmpNode.CheckGroupType = ncgCheckGroup then begin if (tmpNode.CheckState in [cbsChecked]) then begin tmpNode.Delete; end; end; if tmpNode <> nil then begin if tmpNode.HasChildren then begin tmpNode := tmpNode.GetNext; end else begin tmpNode := nil; end; end; end; end; end;
0 条评论
沙发空缺中,还不快抢~