最简单的方法就是,在窗体上放一个Edit1和一个ComboBox1,然后让Edit1完全覆盖ComboBox1,再编写相关事件即可实现你的要求。procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); var i: Integer; begin with ComboBox1 do begin DroppedDown := False; Items.BeginUpdate; try Items.Clear; //动态维护ComboBox的下拉列表项目,这里以Edit1的文本创建10个项目为例 for I:=0 to 9 do Items.Add(Edit1.Text + IntToStr(I)); finally Items.EndUpdate; DroppedDown := True; end; end; end;procedure TForm1.ComboBox1Select(Sender: TObject); begin Edit1.Text := ComboBox1.Text; end;
--------------------
张三
张三丰
张三强
张三秋
Shift: TShiftState);
var
i: Integer;
begin
with ComboBox1 do
begin
DroppedDown := False;
Items.BeginUpdate;
try
Items.Clear;
//动态维护ComboBox的下拉列表项目,这里以Edit1的文本创建10个项目为例
for I:=0 to 9 do
Items.Add(Edit1.Text + IntToStr(I));
finally
Items.EndUpdate;
DroppedDown := True;
end;
end;
end;procedure TForm1.ComboBox1Select(Sender: TObject);
begin
Edit1.Text := ComboBox1.Text;
end;