树状的结构,能不能获取到当前选择的结构路径。
树状的结构,能不能获取到当前选择的结构路径。如上图文件dwg3,如何获得文件结构径为: 【资料文件\\6、资料6\\图纸2\\dwg3 】
下面为二个文件,下载加载查看。
(defun c:Ttt(/ lst odcl_tree_addlist);opendcl的调用
(command "opendcl")
(dcl-Project-Load "C:\\Users\\Administrator\\Desktop\\nuomi\\tree.odcl")
;;;(dcl-Project-Unload "tree" T)
(dcl-form-show tree/Form1)
(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)
)
;多层表添加到tree控件
(setq lst '("资料文件"
("1、资料1"("图纸1""dwg1""dwg2""dwg3"))
("2、资料2"("图纸1""dwg1""dwg2""dwg3"))
("3、资料3"("图纸1""dwg1""dwg2""dwg3"))
("4、资料4"("图纸1""dwg1""dwg2""dwg3"))
("5、资料5"("图纸1""dwg1""dwg2""dwg3"))
("6、资料6"("图纸1""dwg1""dwg2""dwg3")("图纸2""dwg1""dwg2""dwg3"))
))
(dcl-Tree-Clear tree/Form1/TreeControl1);清除数据
(odcl_tree_addlist lst tree/Form1/TreeControl1);加载数据
(defun c:tree/Form1/TreeControl1#OnSelChanged(Label Key /)
(dcl-Control-SetCaption tree/Form1/Label1 Label)
)
)
页:
[1]