OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: krunch on December 20, 2012, 03:24:44 AM

Title: Problem with a ComboBox : how to hold the value ?
Post by: krunch on December 20, 2012, 03:24:44 AM
There something I can't understand in the maintaining of a ComboBox value through a open/close process, I don't know if there's something wrong in my code ..

Here is my sample (see attach) :
(http://img15.hostingpics.net/thumbs/mini_180267Sanstitre2.jpg) (http://www.hostingpics.net/viewer.php?id=180267Sanstitre2.jpg)
When you click on the 'Select' button the form is closed to allow selection.
Values on the right ('Format') are independant of the selection, they display properties read into another object, and can be changed... Entity and Format can be specified in any order.

it appears that the initial ComboBox value is not maintained when the form is closed and open (by clicking on the 'Select' button), while the TextBox value is maintained :
(dialog) > click on 'Select', select something (or not) > the ComboBox 'CurSel' (ie '1' in the sample) is not maintained.

Now :
(dialog) > select manually a value in the ComboBox (for example the same '1' value) > click on 'Select' ... > the value is maintained


Here is the sample code :
Code (autolisp) Select
(defun Dialog (/ out)
    (command "OPENDCL")
    (dcl_Project_Load "Untitled" T)

    (while (not (member out '(1 2)))
        (setq out (dcl_Form_Show Untitled_Form1))
       
        (if (= out 3) (entsel "> Select something : "))
    )
    (if (= out 2) (princ "\n> Cancel"))
    (if (= out 1) (princ "\n> Apply"))
)

(defun c:Untitled_Form1_OnInitialize (/)
  (or out
      ; Initialize the values on first opening only
      (progn
          (dcl_Control_SetText Untitled_Form1_TextBox1 "value")
          (dcl_Control_SetList Untitled_Form1_ComboBox1 '("0" "1" "2"))
          (dcl_ComboBox_SetCurSel Untitled_Form1_ComboBox1 1)
  ))
)
; Select
(defun c:Untitled_Form1_TextButton1_OnClicked (/)
  (dcl_Form_Close Untitled_Form1 3)
)
; Apply
(defun c:Untitled_Form1_TextButton2_OnClicked (/)
  (dcl_Form_Close Untitled_Form1 2)
)
; Cancel
(defun c:Untitled_Form1_TextButton3_OnClicked (/)
  (dcl_Form_Close Untitled_Form1 1)
)
Title: Re: Problem with a ComboBox : how to hold the value ?
Post by: owenwengerd on December 20, 2012, 10:10:16 PM
Only properties of controls are persisted. A combo box does not have a "current item" property, so that aspect of the combo state must be initialized via code each time the combo is displayed. Note that for non-Simple combo styles, the Text property is persisted, but that doesn't help you in this case.