xyz002 发表于 2011-2-12 15:57:44

DCL中两个下拉列表框popup_list如何关联?


如何实现选择a中不同列表值时,b中列表关联变化,值也不同?
如a1对应a1b1,a1b2,a1b3;
a2对应a2b1,a2b2,a2b3;
a3对应a3b1,a3b2;

redcat 发表于 2011-2-14 15:39:22

本帖最后由 redcat 于 2011-2-14 15:41 编辑

拿去吧,比xyp1964要大方

(defun c:ttt (/ data dcl_inf dclhandle)
(defun *error* (msg)
    ;; Error Handler - will unload the dialog
    ;; from memory should the user decide to hit Esc
    (if dclHandle
      (unload_dialog dclHandle)
    )
    (or (wcmatch (strcase msg t) "*break,*cancel*,*exit*,*取消*")
(princ (strcat "\n** Error: " msg " **"))
    )
    (princ)
)

(defun updatelist (key lst)
    (start_list key)
    (mapcar 'add_list lst)
    (end_list)
)
(defun makedcl_str2lst (str_lst / dclfile fileID dclHandle)
    (setq dclfile (vl-filename-mktemp nil nil ".dcl")
   fileID(open dclfile "w")
    )
    (cond
      ((= (type str_lst) 'str)
       (write-line str_lst fileID)
      )
      ((= (type str_lst) 'list)
       (foreach n str_lst (write-line n fileID))
      )
    )
    (close fileID)
    (setq dclHandle (load_dialog dclfile))
    (vl-file-delete dclfile)
    dclHandle
)
(setq dcl_inf "lbox : list_box { width = 25; fixed_width = true; alignment = centered; }\n
                     listboxexample : dialog { label =\"列表对话框教程\";\n
                     spacer;\n: row {\n: lbox { key = \"lst1\"; label = \"列表_1\" ; }\n
                     :lbox { key = \"lst2\"; label = \"列表1关联数据\"; }\n
                     }\n
                     ok_only; \n}"
dclHandle   (makedcl_str2lst dcl_inf)
)

;; Data used to Populate List_Boxes:
;; I've chosen to use this list structure because it suits the data, but there are many other possibilities.
(setq Data
'(("Audi" ("TTS Quattro" "TT RS" "S3 Quattro" "S4 Quattro" "S5 Quattro" "RS5 Quattro" "RS6 Quattro"))
    ("BMW" ("M3" "M5" "M6" "X5" "Z3" "Z4"))
    ("Porsche" ("911" "924" "928" "930" "944" "Boxster" "Cayenne" "Cayman"))
    ("Jaguar" ("XF" "XJ6" "XJR" "XKR" "X-Type" "S-Type"))
   )
)
(cond
    ((not (new_dialog "listboxexample" dclHandle))
   (setq dclHandle (unload_dialog dclHandle))
   (princ "\n** Dialog Definition not Found **")
    )
    (t
   (or *Make* (setq *Make* "0"))
   (or *Model* (setq *Model* "0"))
   ;; Lets set up some default selections, for the first-time running of the program.
   ;; The variables *Make* & *Model* are intended to be global and hence will remember the user's last selections.
   ;; Now to populate the List_Boxes: List_Box 'lst1'
   (UpdateList "lst1" (mapcar 'car Data))
   (set_tile "lst1" *Make*)
   ;; List_Box 'lst2'
   (UpdateList "lst2" (cadr (nth (atoi *Make*) Data)))
   (set_tile "lst2" *Model*)
   (action_tile
       "lst1"
       (strcat "(UpdateList \"lst2\" (setq lst2 (cadr (nth (atoi (setq *Make* $value)) Data))))"
      "(setq *Model*"       "(set_tile \"lst2\""
      " (if (< (atoi *Model*) (length lst2)) *Model* \"0\")""))"
       )
   )
   (action_tile "lst2" "(setq *Model* $value)")
   (start_dialog)
   (setq dclHandle (unload_dialog dclHandle))
    )
)

(princ)
)




xyp1964 发表于 2011-2-12 21:31:38

(defun c:tt (/ elst lst1 lst21 lst22 lst23)
(defun ap1 ()
    (xyp-Dcl-Gettile '("li1" "li2"))
    (cond ((= li1 "0") (xyp-show-list "li2" lst21))
   ((= li1 "1") (xyp-show-list "li2" lst22))
   ((= li1 "2") (xyp-show-list "li2" lst23)))
    (set_tile "li2" li2))
(xyp-initSet '(li1 li2) '("0" "0"))
(setq lst1'("a1" "a2" "a3")
lst21 '("a1b1" "a1b2" "a1b3")
lst22 '("a2b1" "a2b2" "a2b3")
lst23 '("a3b1" "a3b2" "a3b3")
elst'(("" "tt" ":boxed_column{")
("li1" "a" "poplist" "lst1" "16" "(ap1)")
("li2" "b" "poplist" "lst21" "16")
"spacer;"
"}"
"spacer;"
(nil nil "user" "(ap1)")))
(xyp-Dcl-Init elst "【tt】" t)
(princ)
)


洪少(刀模) 发表于 2018-7-17 10:50:48

我还是不是很明白,重新发了贴了。希望能理解

ZZXXQQ 发表于 2011-2-12 16:21:00

本帖最后由 ZZXXQQ 于 2014-9-11 19:12 编辑

……
(setq pop1 '("a1" "a2" "a3"))
(setq pop2 '(("a1b1" "a1b2" "a1b3") ("a2b1" "a2b2" "a2b3") ("a3b1" "a3b2")))
……
(action_tile "a" "(chpop (atoi $value))")
……
(defun chpop (c)
(start_list "b")
(mapcar 'add_list (nth c pop2))
(end_list)
)

xyz002 发表于 2011-2-14 11:43:57

多谢二位版主,XYP-INITSET函数在哪下载?

xyz002 发表于 2011-2-15 11:59:25

多谢redcat

zhuquanmao 发表于 2012-10-22 14:32:49

ZZXXQQ 发表于 2011-2-12 16:21 static/image/common/back.gif
……
(setq pop1 '("a1" "a2" "a3"))
(setq pop2 '(("a1b1" "a1b2" "a1b3") ("a2b1" "a2b2" "a2b3") ("a3 ...

stat_LIST是笔误 改为了start_LIST还是不行呢?

jyzas 发表于 2013-7-27 23:19:45

正在找下拉资料,谢谢楼上的分享

jyzas 发表于 2013-7-27 23:40:56

请教下怎样在下拉框里输入数字

Kye 发表于 2014-9-11 14:19:58

ZZXXQQ 发表于 2011-2-12 16:21 static/image/common/back.gif
……
(setq pop1 '("a1" "a2" "a3"))
(setq pop2 '(("a1b1" "a1b2" "a1b3") ("a2b1" "a2b2" "a2b3") ("a3 ...

感谢Z版,把(action_tile "a" ( "(chpop (atoi $value))"))=>(action_tile "a" "(chpop (atoi $value))") 就OK了,再次膜拜Z版
页: [1] 2
查看完整版本: DCL中两个下拉列表框popup_list如何关联?