Hello,
my problem is to get the ItemIndex of a selection in a MultiSelect control. I know it is a "Multi"Select control, but I use it because it is much more comprehensible for the user. I fill the Selector.Items out of a database and at a click on 1 item I have to get the index number of the selected item.
I tried this code, but it doesn´t work because recno is always -1:
Do I misunderstand ArrayIndexOf ? Thanks for your help.
kind regards,
Walter
Hello Walter,
In a Multiselect control we do not have an "ItemIndex" variable like in the Select control. What we have is an "Items" variable and an "SelItems" variable. Since "SelItems" variable contains the selected items, if a user choose one item, then the "SelItems" variable contains one element with the selected item value.
From that value we can use the ArrayIndexOf action over the select items array in order to get the selected item index. Take a look at the bellow code, which you can put in a "Change" event of a Multiselect control (which contains a few items):
Note that in the above code we also check the user select more than one item. If so, we take the first of the selected items and omit all others. If you have any other doubt do not hesitate to post here Walter.
Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.