0

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.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by TomRandall
0

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;

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.