Hi All,

This is probably a stupid question, and I could have easily written a small function that loops over the values and selects the first match... but I'd prefer to use the built in way - if there is one.

Is there a built in function to select a dropdown list item by name when the style is set to csDropDownList? For example, if I had

"One", "Two", "Three" and wanted it to select "Three" (not using ItemIndex := 2 because the positions won't be fixed, and can't use .Text := "Three") is there a way?

Thanks.

Recommended Answers

All 2 Replies

Hi All,

This is probably a stupid question, and I could have easily written a small function that loops over the values and selects the first match... but I'd prefer to use the built in way - if there is one.

Is there a built in function to select a dropdown list item by name when the style is set to csDropDownList? For example, if I had

"One", "Two", "Three" and wanted it to select "Three" (not using ItemIndex := 2 because the positions won't be fixed, and can't use .Text := "Three") is there a way?

Thanks.

TComboBox.Items(Tstring) ->you can use indexOf ->
i:=ComboBox1.Items.IndexOf('Three');
if i>-1 then
ComboBox1.ItemIndex:=i;

Thanks, perfect!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.