Thanks for your reply Aaron,
Actually when I said "select" I meant "highlight" an item in the ListBox. In
fact I want the highlighting to follow the ItemIndex.
I tried setting Multiselect to true and it works but I don't want the user
to be able to select more than one at a time. Maybe I'll just have to
explicitly un-select every item every time I select another (and every time
the user clicks on one).
Richard Williams
From: Aaron Scott-Boddendijk <[EMAIL PROTECTED]>
>How do I select a list box control (using code). I've tried using say
>if ListBox1.items.count > 0 then
> ListBox1.selected[0] := true;
>but I get an exception "List Index out of bounds (0)". The help indicates
that
>"selected" can be used to check if the current line is selected but doesn't
> say if you can use it to set it.
Is multiselect turned on... If not then the selected item is indicated by
the ItemIndex
property. It's possible that the Selected[n] array property is not
populated unless
multiselect is true.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz