This should do something like you have described, if you want to make your
own TComboBox derirative.

Regards, 
Paul Marshall

{----------------------------------------------------------}
{                        AutoPrompt                        }
{----------------------------------------------------------}

{ If AutoPrompt is turned on, the control will look to see
  whether the text being entered matches the start of any
  of the strings in the control's list. If so, it will add
  the rest of the text and click to alert the user.

  The part of the string that has been added automatically
  is selected, so the user can keep typing without causing
  a problem.

  Three or more characters must have been typed before the
  AutoPrompt kicks in. }

procedure TMyComboBox.KeyPress(var Key: Char); { override }
var j,l:integer;
    UCText,UCItem:String;
begin
  if FAutoPrompt and not (Key = #8 {backspace} ) then
  begin
    UCText := Text;
    UCText := Uppercase(Copy(UCText,1,SelStart) + Key +
                        Copy(UCText,SelStart + SelLength +
1,Length(UCText)));
    l := Length(UCText);
    if (l >= 3) and (SelStart + 1 = l) then
      begin
        for j := 0 to Items.Count - 1 do
          begin
            UCItem := Uppercase(Copy(Items[j],1,l));
            if (UCText = UCItem) then
              begin
                Text := Items[j];
                SelStart := l;
                SelLength := Length(Text) - SelStart;
                if (l=3) then
                  MessageBeep($FFFFFFFF); { click noise }
                Key := #0;
                Change; { do an OnChange event }
                Break;
              end;
          end;
      end;
  end;
  inherited KeyPress(Key);
end; { KeyPress }


> -----Original Message-----
> From: Mark Howard [SMTP:[EMAIL PROTECTED]]
> Sent: Saturday, August 12, 2000 4:12 AM
> To:   Multiple recipients of list delphi
> Subject:      [DUG]:  Special ComboBox
> 
> Hello
> Does anyone have (or can refer me to) a ComboBox component that will
> incrementally home in on an entry in it's listbox as further keys are
> pressed (ie rather than repositioning the cursor at the first item in the
> list beginning with each subsequent keypress). - so keying B and then R
> would position the cursor on the first item in the list beginning with BR.
> Thanks
> Mark
>  
>  
>  
>  
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to