with adoquery1 do begin active:=false; active:=true; if recordcount>0 then begin first; while not eof do begin combobox1.items.add(trim(fieldbyname('field').asstring)); next; end; combobox1.itemindex:=0; end; end; ________________________________ 做个调查,关于软件界面 http://expert.csdn.net/Expert/TopicView2.asp?id=1649010 谢谢关注
adoquery1.sql.clear; adoquery1.sql.add('select field1 from table1 group by field1'); with adoquery1 do begin active:=true; if recordcount>0 then begin first; repeat combobox1.items.add(adoquery1field1.asstring); next; until eof ; combobox1.itemindex:=0; end; end;
其实用table控件也可以,当然那combobox的items的数据内容就不是查询出来的,是数据库中的某个字段内容,也挺好用的: var i,j:integer; begin j:=table1.recordcont; for i:=0 to j-1 do table1.moveby(i); combobox1.items.add(table1.fieldbyname('field'));//field为数据库中的某字段 end;我就这样添加combobox的items的值,也挺好用的.
小错误,更正:var i,j:integer; begin j:=table1.recordcont; for i:=0 to j-1 do begin table1.moveby(i); combobox1.items.add(table1.fieldbyname('field'));//field为数据库中的某字段 end; end;
begin
active:=false;
active:=true;
if recordcount>0 then
begin
first;
while not eof do
begin
combobox1.items.add(trim(fieldbyname('field').asstring));
next;
end;
combobox1.itemindex:=0;
end;
end;
________________________________
做个调查,关于软件界面
http://expert.csdn.net/Expert/TopicView2.asp?id=1649010
谢谢关注
adoquery1.sql.add('select field1 from table1 group by field1');
with adoquery1 do
begin
active:=true;
if recordcount>0 then
begin
first;
repeat
combobox1.items.add(adoquery1field1.asstring);
next;
until eof ;
combobox1.itemindex:=0;
end;
end;
var i,j:integer;
begin
j:=table1.recordcont;
for i:=0 to j-1 do
table1.moveby(i);
combobox1.items.add(table1.fieldbyname('field'));//field为数据库中的某字段
end;我就这样添加combobox的items的值,也挺好用的.
begin
j:=table1.recordcont;
for i:=0 to j-1 do
begin
table1.moveby(i);
combobox1.items.add(table1.fieldbyname('field'));//field为数据库中的某字段
end;
end;