[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1197
  • Last Modified:

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
0
A. Cristian Csiki
Asked:
A. Cristian Csiki
  • 2
  • 2
1 Solution
 
2266180Commented:
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now