We help IT Professionals succeed at work.

Set Selected item in list box

Chipmunk77
Chipmunk77 asked
on
Medium Priority
457 Views
Last Modified: 2010-04-04
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
Comment
Watch Question

Mike LittlewoodEngineer
Commented:
ListBox.ItemIndex := Listbox.Items.IndexOf( 'This string')

Something like that?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Commented:
Set the itemindex property

e.g. Listbox1.ItemIndex:= 1

Author

Commented:
Thanks all, that's what I get for trying to multitask!  Can't think straight!
TheRealLokiSenior Developer
CERTIFIED EXPERT

Commented:
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;
CERTIFIED EXPERT

Commented:
Why a B grade?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.