Hi I have created a search application. It works well searching for one variable however, I would like to search for more then one variable in the TEdit box.
How can I do this? perhaps there is a search package that will do this for me?
Eample:
I have added a Edit1, ListBox1, Listbox2 and Button1 to my Form1.
I search for "Firstline" and it returns, I search for "1random" and it returns.
However when I search for "Firstline, 1random" I get nothing.
How can I make this possible? I was thinking of using comma delimited somehow but if there is an easier way i'll be happy.
Any suggestions or improvements will be greatly appreciated.
Windows 10 x64
Lazarus IDE v1.6.4
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ListBox1: TListBox;
ListBox2: TListBox;
procedure Button1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: char);
procedure FormCreate(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
i: Integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox2.Clear;
for i:= 0 to ListBox1.Items.Count-1 do begin
if UpperCase(ListBox1.Items[i]) = UpperCase(Edit1.Text) then
ListBox2.Items.Add(ListBox1.Items[i]);
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char);
begin
if (Key = chr(10)) or (Key = chr(13)) then begin
Button1Click(Sender);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Items.Clear;
ListBox1.Items.Add('Firstline');
ListBox1.Items.Add('1random');
ListBox1.Items.Add('Third');
ListBox1.Items.Add('2random');
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
end;
procedure TForm1.ListBox2Click(Sender: TObject);
begin
end;
end.