Board index » delphi » Listbox question

Listbox question

How do you find the intemindex of an item selected
in a listbox?

kjc
*************************************************
An anti-spam email address has been used.
To return an email change '@' to @ .

 

Re:Listbox question


I think you are wanting to find the "itemIndex" of an item.

if the listbox was listBox1, then the itemIndex would be just
listBox1.itemIndex.

Quote
kjc wrote in message <34674af7.37088...@news.demon.co.uk>...
>How do you find the intemindex of an item selected
>in a listbox?

>kjc
>*************************************************
>An anti-spam email address has been used.
>To return an email change '@' to @ .

Re:Listbox question


Quote
>   k...@gemnet.demon.co.uk (kjc) writes:
>  How do you find the intemindex of an item selected
>  in a listbox?

If you do not have multiselect then itemindex is the selected item. -1 if no item is selected.
If you have multiselect on there is a propery for each item called selected.

         for i := 0 to adrkodlista.items.count -1 do begin
           if adrkodlista.selected[i] then
             destanv.items.add (adrkodlista.items[i]);
         end;//for i

This routine goes through all items in one listbox and if one item is selected it is added to another listbox.

johan

Other Threads