Bir listbox icerisinden secilerek baska bir alana, örnegin bir edit kontrolüne atanacak degerlerin secim icin, artan arama yapilabilir. Artan arama , edit icerisine yazdiginiz bilgiye uygun olan ListBox elemaninin otomatik olarak secili hale gelmesi demektir.
Kod örnegi asagidadir.
unit incsearch;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
// ComboBox'un icine birseyler doldurun
end;
procedure TForm1.Edit1Change(Sender: TObject);
var
S : Array[0..255] of Char;
begin
StrPCopy(S, Edit1.Text);
with ListBox1 do
ItemIndex := Perform(LB_SELECTSTRING, 0, LongInt(@S));
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then edit1.text:=listbox1.Items[listbox1.itemindex];
end;
end.