用adoquery查询返回的数据。
combobox.Items.Clear;
with adoquery1 do
begin
while not eof do
begin
comcobox.Items.Add(fieldbyname('id').asstring);
next;
end;
end;
窗口显示代码?不太明白是不是这样?
Frm2:=TFrm2.Create(application);
Try
Frm2.ShowModal;
Finally
Frm2.free;
Frm2:=nil;
end;
一、窗体显示的时候
cbb1.clear
while not qry1.eof do begin
cbb1.items.add(qry1.FieldbyName('字段').AsString);
qry1.next;
end;
二、ONSelect事件中
代码同上
例如:我要显示表sale中的第一个数据!这里要需要添加一个组件"TADOdataset",我的组件"TADOdataset"改名为“adssale”,“TADOdataset”里面的部分属性需要你自己修改!
procedure Tsale.ComboBox1Change(Sender: TObject);
begin
dbcombobox1.ItemIndex:=combobox1.ItemIndex;
dm.adssale.Edit;
dm.adssale.Fields[0].AsString:=dbcombobox1.Text;
end;