Recent

Author Topic: [SOLVED] Quick question about TListBox  (Read 1077 times)

SteveSS

  • New Member
  • *
  • Posts: 43
[SOLVED] Quick question about TListBox
« on: December 17, 2019, 05:56:12 pm »
Is it possible to process the items in a TListBox and do something with each one that has been selected by the user ... e.g.

for i := 0 to listbox.items.count - 1 do
begin
  if listbox.items.selected = true then
    do something ......
end;

I know that .selected is not available but can't find any way of identifying which items are selected and which are not.  I don't want to remove the item - just do some processing on it then de-select it.

Merry Christmas to you all!!

Steve
« Last Edit: December 17, 2019, 06:17:59 pm by SteveSS »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4720
  • I like bugs.
Re: Quick question about TListBox
« Reply #1 on: December 17, 2019, 06:12:39 pm »
for i := 0 to listbox.items.count - 1 do
begin
  if listbox.items.selected = true then
    do something ......
end;
Almost...
Code: Pascal  [Select][+][-]
  1. for i := 0 to listbox.items.count - 1 do
  2. begin
  3.   if listbox.selected[i] then
  4.     do something ......
  5. end;
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

SteveSS

  • New Member
  • *
  • Posts: 43
Re: Quick question about TListBox
« Reply #2 on: December 17, 2019, 06:17:19 pm »
Thanks JuhaManninen.  Works perfectly - I knew there would be a simple solution - just couldn't find it.

Thanks again.

Steve

 

TinyPortal © 2005-2018