compare string with combobox items

hi experts,
I've a little problem which seems to be easy but I can't found the clue. I want to check if a string is an item from an combobox?

I tried :

var i:integer;
     s:string;
...
s:='data';
 for i:=0 to combobox1.Items.Count do
    if  combobox3.Items.Text=s then
// do something

but won't work. Thanks for help
LVL 11
A. Cristian CsikiSenior System AdministratorAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
try
if combobox3.items.indexof(s)>-1 then
// exists
else
// does not exist
0
 
A. Cristian CsikiSenior System AdministratorAuthor Commented:
thanks a lot, it fits :)
and if I want to found the item can I make it visible in combobox?
ex: I found data as the 4-th item of my combobox, can I set the combobox to itemindex 5 to display my item found?
0
 
2266180Commented:
sure.
i:=combobox3.items.indexof(s);
f i>-1 then
  combobox3.itemindex:=i;
0
 
A. Cristian CsikiSenior System AdministratorAuthor Commented:
perfect! thanks
0
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.

All Courses

From novice to tech pro — start learning today.