I am trying to set a ComboBox
's text conditionally - that is, if the text I am setting it to exists in the box's Items
, then set it to that. Otherwise, leave it blank.
e.x.
ComboBox's Items:
- Green
- Blue
- Pink
- Red
For ComboBox1 I am trying to set to "Red". Because that string exists in the Items, the text property is set to "Red". For ComboBox2 I am trying to set to "Yellow", which doesn't exist, so I want that text empty (but the previous items still are there).
All the comboboxes will have the same Items. However, there are lots of combo's so I'm trying to avoid looping through each boxes owns items and compare each one. In C# you could just do something like:
ComboBox1.ItemIndex := 'My Text';
Which doesn't compile here.