OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: andrew on February 22, 2013, 06:46:36 AM

Title: change item in combo box drop down when selected
Post by: andrew on February 22, 2013, 06:46:36 AM
Im trying to have the item list in a drop down combobox change after its selected but im having a brain fart

in the combobox properties i have set:
style = combo
list = A|B|C|.. etc

Events i have set:
Selchanged

here is the code im starting with

(defun c:dwg-num_New_ComboBox1_OnSelChanged (ItemIndex ItemValue /)
  (if (= ItemValue "A")
  (progn
  (dcl_ComboBox_Clear dwg-num_New_ComboBox1)
(dcl_Control_SetText dwg-num_New_ComboBox1 "a-12345")
;(dcl_Control_SetList dwg-num_New_ComboBox1(list "a-12345"))
)
  )
)


so when the project is loaded in the combo box you will see
A
B
C
.. etc

when A is selected i want A to be replaced with a number (example A-12345) that will be generated by which letter is selected
my problem (right now) is that i cannot get the A-12345 to appear.

the whole list clears but trying to "set" the item just makes it blank.

if i use the "setlist" function it puts the number there, but i have to then go back to the combo box and reselect it.


what am i missing/doing wrong?
how can i get it to show and without having to go back to the drop down and selecting it?
Title: Re: change item in combo box drop down when selected
Post by: roy_043 on February 22, 2013, 11:29:20 AM
Quote from: andrew on February 22, 2013, 06:46:36 AM
if i use the "setlist" function it puts the number there, but i have to then go back to the combo box and reselect it.
So just use the (dcl_ComboBox_SetCurSel) function.

Example:
Code (autolisp) Select

(defun c:TestCombo ( / lst)
  (setvar 'cmdecho 0)
  (command "OPENDCL")
  (setvar 'cmdecho 1)
 
  (setq lst '("AA" "BB" "CC" "DD" "EE"))
 
  (dcl_Project_Load "TestCombo" T)
  (dcl_Form_Show TestCombo_Form1)
)

(defun c:TestCombo_Form1_ComboBox1_OnSelChanged (itemIndexOrCount value /)
  (setq lst (subst (strcat value "-12345") value lst))
  (dcl_Control_SetList TestCombo_Form1_ComboBox1 lst)
  (dcl_ComboBox_SetCurSel TestCombo_Form1_ComboBox1 itemIndexOrCount)
)

(defun c:TestCombo_Form1_OnInitialize ()
  (dcl_Control_SetList TestCombo_Form1_ComboBox1 lst)
)
Title: Re: change item in combo box drop down when selected
Post by: owenwengerd on February 23, 2013, 09:51:19 AM
Quote from: andrew on February 22, 2013, 06:46:36 AM
how can i get it to show and without having to go back to the drop down and selecting it?

If you use SetList to replace the dropdown list, you don't need to call Clear. You could also Clear and AddString (or AddList) to replace the dropdown list. In either case you have to SetCurSel to select something. SetText only sets the text in the edit control of the combo box.
Title: Re: change item in combo box drop down when selected
Post by: andrew on February 25, 2013, 06:53:08 AM
thank you for the reply

setcursel was the ticket