exo
exo

Reputation: 69

Delphi - How to check if a listBox contains specified string?

I have a listbox with items.I am looping through the listbox to get one item at once and to be assigned to a string variable.The question is.. Is there a way to check wether the list contains specified string? Thanks in advance.

Upvotes: 5

Views: 11635

Answers (1)

Obl Tobl
Obl Tobl

Reputation: 5684

Try it this way:

if ListBox1.Items.IndexOf('yourString') > -1 then
begin
  //whatever you want to do if your listbox contains 'yourString'
end;

Upvotes: 14

Related Questions