Steve,

try
http://www.delphi3000.com/articles/article_560.asp

Works alright, but only problem is you have to press Esc to re-run the
search. I haven't had a play, but it shouldn't take too much hacking to fix
that.

Cheers

James

-----Original Message-----
From: Stephen Barker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 23 May 2001 15:42
To: Multiple recipients of list delphi
Subject: [DUG]: TComboBox keys


Hi,

does anyone know how to make a TComboBox do incremental searching?

by default it only seems to search on the first character.

I tried concatenating key values and setting the itemindex to the correct
item, but the default behaviour still takes over.

in the keydown event I have:

procedure TfrmMain.cboProjectKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  i : integer;
begin
  if (Key >= ord('0')) and (Key <= ord('9')) then begin
    ProjKey := ProjKey + chr(Key);
    i := 0;
    while (i < cboProject.Items.Count) and
(copy(cboProject.Items[i],1,length(ProjKey)) <> ProjKey) do
      inc(i);
    // i := cboProject.Items.IndexOf(ProjKey);
    if i = cboProject.Items.Count then i := 0;
    cboProject.ItemIndex := i;
    Key := 0;
  end;
end;

thanks,
Steve
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"



CAUTION - This message may contain privileged and confidential information intended 
only for the 
use of the addressee(s) named above.  If you are not the intended recipient of this 
message you are 
hereby notified that any use, dissemination, distribution or reproduction of this 
message is prohibited.  
If you have received this message in error please notify Progressive Enterprises Ltd. 
immediately via 
email at [EMAIL PROTECTED]  Any views expressed in this message 
are those of the 
individual sender and may not necessarily reflect the views of Progressive Enterprises 
Ltd.

This footnote also confirms that Progressive Enterprises Ltd. has swept this email 
message for the 
presence of computer viruses.  This does not guarantee this message is virus free.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to