delphi中 点击combobox下拉框中的编号 如何将与编号有关的信息如商品名称 出版社等信息显示到edit里面

或者是edit的下拉列表
2025-03-16 01:33:44
推荐回答(2个)
回答(1):

procedure TForm1.ComboBox1Select(Sender: TObject);
begin
with ADOQuery1 do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from product where id=' + ComboBox1.Text);
ADOQuery1.Open;
Edit1.Text := ADOQuery1.FieldByName('商品名称').Value;
//Edit2.Text := ADOQuery1.FieldByName(' ').Value;
//............其他数据
end;
end;

回答(2):

如果是用adoquery的话,用Locate方法查找记录
aqu.Locate('编号',combobox1.text,[]);
edit1.text:=aqu.fieldbyname('名称').asstring;
....