多层表添加到tree控件,求优化代码!~~
;多层表添加到tree控件(defun odcl_tree_addlist(LST TreeControl / KEY addlist)
(SETQ KEY (dcl_Tree_AddParent TreeControl (list (list(car lst)))))
(defun addlist(lst key / x key1 kl)
(foreach x lst
(if (listp x)
(setq key1 (dcl_Tree_AddChild TreeControl(list (list key (car x))))
kl (addlist (cdr x) key1)
)
(setq key1 (dcl_Tree_AddChild TreeControl (LIST(list key x))))
)
)
);defun addlist
(addlist (cdr lst) key)
(PRINC)
)测试数据:
(setq lst '("总分类"
"A没有子分类"
"B没有子分类"
;POP1
("分类1"
"分类11"
("分类12"
"分类121"
("分类122"
"分类1221"
"分类1222"
"分类1223"
)
"分类123"
"分类124"
"分类125"
"分类126"
"分类127"
)
"分类13"
)
;POP2
("分类2"
"分类21"
"分类22"
"分类23"
"分类24"
"分类25"
"分类26"
)
;POP3
("分类3"
"分类31"
"分类32"
"分类33"
"分类34"
"分类35"
"分类36"
"分类37"
"分类38"
"分类39"
)
)
)
测试结果:
回帖是一种美德!感谢楼主的无私分享 谢谢 回帖是一种美德!感谢楼主的无私分享 谢谢 回帖是一种美德
页:
[1]