Board index » delphi » LISTBOX HELP...MULTISELECT

LISTBOX HELP...MULTISELECT

I am having problems with listboxes, how do I use the multiselect property
to get certain items out of the listbox....I know I use the selcount like:

for x := 0 to listbox1.selcount do
begin
    (* now, how do I get the 1st item and return it, the 2nd selected item,
etc*)
end;

Thanks

 

Re:LISTBOX HELP...MULTISELECT


procedure TForm1.Button1Click(Sender: TObject);
var
  x: integer;
begin
  for x := 0 to listbox1.items.count-1 do
  if listbox1.selected[x]
    then ShowMessage(listbox1.Items[x]);
end;

Ryan Rife <rif2...@multipro.com> wrote in article
<3496790...@news2.kcdata.com>...

Quote
> I am having problems with listboxes, how do I use the multiselect
property
> to get certain items out of the listbox....I know I use the selcount
like:

> for x := 0 to listbox1.selcount do
> begin
>     (* now, how do I get the 1st item and return it, the 2nd selected
item,
> etc*)
> end;

> Thanks

Re:LISTBOX HELP...MULTISELECT


Hmm! :)

Ryan Rife <rif2...@multipro.com> wrote in article
<3496790...@news2.kcdata.com>...

Quote
> I am having problems with listboxes, how do I use the multiselect
property
> to get certain items out of the listbox....I know I use the selcount
like:

> for x := 0 to listbox1.selcount do
> begin
>     (* now, how do I get the 1st item and return it, the 2nd selected
item,
> etc*)
> end;

1) Go through Selected property:
    for x := 0 to listbox1.Items.Count-1 do if ListBox1.Selected[x] then
...

2) Using WINAPI:
  var indexes: array[0..99] of Integer; idxcount: Integer;
  idxcount := listbox.Perform(LB_GETSELITEMS, 100, LongInt(@indexes));
  for x := 0 to idxcount-1 do ...

Dmitry.

Other Threads