dcl-control-setlist and sorted comboboxes

Started by Peter2, June 06, 2017, 07:01:26 AM

Previous topic - Next topic

Peter2

Just to inform the other users which want to avoid the mistake I made.

a) I have a combo-box with property "Sorted".

b) I have a list which is not (exactly) sorted:
Code (autolisp) Select
(setq namelist (list "Adam" "John" "Jim" "Susan"))

c) I have a variable called "Name" which can continue Adam, John, ....

d) In "OnInitialize", I want to set the current value of the combobox to the current value of "name"
Code (autolisp) Select

    (dcl-combobox-clear mydialogue/mycombo); only to clear
    (dcl-Control-SetList mydialogue/mycombo namelist) ; names from above
    (dcl-ComboBox-SetCurSel mydialogue/mycombo (vl-position name namelist))


You see the problem? "Adam" and "Susan" will have no problem, but e.g. "Jim": vl-position gives me value 2 (third position), but the sorted-combobox puts "Jim" before "John". So "Jim" (3rd in namelist) will return "John" (3rd in sorted list).

If nobody needs this, then it is just for me if I forget after some time  ;)
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

marcoheuer

hello peter2,
use dcl-ComboBox-SelectString instead of dcl-ComboBox-SetCurSel

best regards
marco
Marco Heuer
Dipl. Ing.
www.arc-aachen.de
Airport Office

Peter2

Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10