1
combobox1.changing or keypress
begin
  if b='B' then
  combobox1.text := ... else
  if ...
end;
2: case of 

解决方案 »

  1.   

    keypress
    if combobox1.onenter 才可以
      

  2.   

    设置 ComboBox1.Style := csDropDownList; 即可。
    因为 TComboBox 自带此功能。或者, 若 Sytle := csDropDown; 则在 OnChange 事件中写程序。
    //
    procedure ComboBox1Change(Sender: TObject);
    var
       strText: String;
       intNo, intCount: Integer;
    begin
       if Sender is TComboBox then
          with Sender as TComboBox do
          begin
             strText := Text;
             intCount := Items.Count;
             intNo := 0;
             while intNo < intCount do
             begin
                if Pos(strText, Items[intNo]) > 0 then
                begin
                   ItemIndex := intNo;
                   Text := strText;
                   break;
                end;
                Inc(intNo)
             end;
          end;
    end;