dcl-control-setlist and sorted comboboxes

Started by Peter2 · 2017-06-06 14:01 UTC · 2 replies · SMF topic #2513

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: (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"

    (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  ;)
hello peter2,
use dcl-ComboBox-SelectString instead of dcl-ComboBox-SetCurSel

best regards
marco
Thanks Marco

helpful as always  :)