MultiSelect control - index of SelItem(s)


Walter Hiller

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


DecSoft

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.


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.