• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

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?

2 Solutions
ListBox.ItemIndex := Listbox.Items.IndexOf( 'This string')

Something like that?
Pierre CorneliusCommented:
Set the itemindex property

e.g. Listbox1.ItemIndex:= 1
Chipmunk77Author Commented:
Thanks all, that's what I get for trying to multitask!  Can't think straight!
TheRealLokiSenior DeveloperCommented:
if you have "MultiSelect" set to tru though, you will need to set each item as selected manually
  listbox1.Selected[1] := true;
  listbox1.Selected[2] := true;
Pierre CorneliusCommented:
Why a B grade?
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.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now