OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Peter2 on June 06, 2017, 07:01:26 AM

Title: dcl-control-setlist and sorted comboboxes
Post by: Peter2 on June 06, 2017, 07:01:26 AM
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  ;)
Title: Re: dcl-control-setlist and sorted comboboxes
Post by: marcoheuer on June 07, 2017, 06:10:24 AM
hello peter2,
use dcl-ComboBox-SelectString instead of dcl-ComboBox-SetCurSel

best regards
marco
Title: Re: dcl-control-setlist and sorted comboboxes
Post by: Peter2 on June 14, 2017, 12:07:48 PM
Thanks Marco

helpful as always  :)