Set Selected item in list box

Hi all,

I'm having trouble figuring out how to set a selected item in a list box.  I have the text that I want to find, but the DoFindData is an inherited protected function.  I can also find the index of the row, but the SetItemIndex is also an inherited protected function so I am unable to use either one of these.  Any ideas on how I can choose what row is selected in the TListBox?

Thanks
Chipmunk77Asked:
Who is Participating?
 
Pierre CorneliusConnect With a Mentor Commented:
Set the itemindex property

e.g. Listbox1.ItemIndex:= 1
0
 
mikelittlewoodConnect With a Mentor Commented:
ListBox.ItemIndex := Listbox.Items.IndexOf( 'This string')

Something like that?
0
 
Chipmunk77Author Commented:
Thanks all, that's what I get for trying to multitask!  Can't think straight!
0
 
TheRealLokiSenior DeveloperCommented:
if you have "MultiSelect" set to tru though, you will need to set each item as selected manually
eg.
  listbox1.Selected[1] := true;
  listbox1.Selected[2] := true;
0
 
Pierre CorneliusCommented:
Why a B grade?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.