Re: Searching in a listbox

[ Related Articles and Replies ] [ DelphiLand FAQ ] [ Delphi Tutorials ]

Posted by webmaster Guido on November 27, 2001 at 18:47:18:

In Reply to: Webmaster Guido, question about an old post of yours posted by Michael Ross on November 22, 2001 at 20:33:21:

: In the post:
: You provide a way to search a listbox incrementally.
: Your code works great!

: My question is: Where, in that code, could I place a MessaeDlg informing if "No Matches Found"?

: Have already preceded the code with:

If Edit1.text = '' then begin //check to make sure text has been entered
  MessageDlg('Please enter the text you wish to search for', mtError, [mbOK], 0);
  Edit1.SetFocus; //set focus if no text entered.
  Exit; //quit subroutine if the edit box is empty

: But am having no luck figuring where to put the "No Matches Found" message.


You can change the last line of the routine:

if Found then LB.ItemIndex := i;

to the following:

if Found then LB.ItemIndex := i
else MessageDlg('No match found', mtWarning, [mbOk], 0);

For those of you who want to follow along, you can open a new window with the original message and code by clicking here: Message 512

Related Articles and Replies

[ Related Articles and Replies ] [ DelphiLand Discussion Forum ]