Beranda > Delphi > Incremental search of list box

Incremental search of list box

The following code implements incremental search of list box using text typed into edit control.

procedure TListBoxSearchForm.Edit1Change(Sender: TObject) ;
const
  indexStart = -1;
var
  search : array[0..128] of Char;
begin
  //make sure Length(Edit1.Text) <= 128
  StrPCopy(search, Edit1.Text) ;
  ListBox1.ItemIndex := ListBox1.Perform(LB_SELECTSTRING, indexStart, LongInt(@search)) ;
end;
Iklan
Kategori:Delphi
  1. Carlos
    April 22, 2009 pukul 1:31 am

    When you try to find a string that don’t appears in the listbox you got an exception
    EStringListError

    ListIndex outof bouns (-1)
    How I could solve this?
    Thanks!!

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: