1. Computing & Technology

Discuss in my forum

in Delphi VCL ::
Imagine a list box with a huge number of (unsorted) items. Finding the one user wants to select might turn into a nightmare. Let's provide the user with an option to immediately locate the item in the list box by adding incremental search functionality.

Read the full article to learn how to Implement Incremental Search for the TListBox Delphi Control

Related:

Comments
December 7, 2009 at 7:03 am
(1) Michael Rockett :

I’ve been looking for something like this for quite a while now – thank you for posting this. :)

December 9, 2009 at 1:21 am
(2) delphigeist :

Unfortunately this does not work as you expect Michael, a better implementation would be to write this code on edit’s OnChange event

var i : integer;
begin
for i := 0 to Listbox.items.count -1 do
if Pos(edit.text, Listbox.items[i]) > 0 then begin
listbox.itemindex := i;
break;
end;
end;
in this way, the first item in listbox that contains your text will be highlighted.
Note that I wrote this code without a IDE or testing, but you are welcomed to test it.

March 23, 2010 at 6:02 am
(3) GM :

@Zarko

Thank u very much, the code work great

@delphigeist
Thank u too
and if u want the Zarko’s code work with u then u should not enable sorted properties, if u do that the code will not work

Instead, put in the form create events this:
listbox1.sorted:=true;

That’s it.

Good luck 2 all.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>
Related Searches incremental search delphi

©2012 About.com. All rights reserved.

A part of The New York Times Company.