As far as I know, if the list contents in TComboBox is sorted, it
automatically do incremental searching.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Stephen Barker
Sent: Wednesday, 23 May 2001 3:42 p.m.
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"

---------------------------------------------------------------------------
    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