procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(ComboBox1.Text); end;
貌似 AutoComplete 属性就是干这个的吧,而且默认是 true
procedure TForm1.ComboBox1Change(Sender: TObject); function IsSame(Textstr,Itemstr:string):boolean; begin result:=false; if textstr=copy(itemstr,1,length(itemstr)) then result:=true; end; var i:integer; begin for i:=0 to combobox1.Items.Count-1 do if not issame(combobox1.Text,combobox1.Items[i]) then combobox1.Items.Delete(i); end;
begin
ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(ComboBox1.Text);
end;
function IsSame(Textstr,Itemstr:string):boolean;
begin
result:=false;
if textstr=copy(itemstr,1,length(itemstr)) then
result:=true;
end;
var
i:integer;
begin
for i:=0 to combobox1.Items.Count-1 do
if not issame(combobox1.Text,combobox1.Items[i]) then
combobox1.Items.Delete(i);
end;