Pages

Wednesday, December 21, 2011

How to search TStringlist Item in delphi

Sometimes we need to know whether a string is contained in a stringlist. This post will discuss about how to find a string inside the stringlist. If it is found, it will return true, otherwise false. Here is the sample code :
var MyList:TStringlist;
    Found:Boolean;
begin
 if MyList.IndexOf('item name') = -1 then
   Found := false
 else
   Found := true;
end;

1 comment:

  1. function TfrmForm.IsItemFoundInList(AslList: TStringList; AsText: String): Boolean;
    begin
    Result := AsList.IndexOf(AsText) > -1;
    end;

    ReplyDelete

Don't Forget To Join Our Community
×
Widget