delphi下拉列表关联显示不出数据
代码如下可是combobox显示不出数据这是为什么procedureTForm1.ComboBox1Change(Sender:TObject);begincombobo...
代码如下可是combobox显示不出数据 这是为什么 procedure TForm1.ComboBox1Change(Sender: TObject);begin combobox1.Items.Clear; with ADOQuery1 do begin close; sql.Add('select department from codes'); open; end; while not ADOQuery1.eof do begin combobox1.Items.Add(ADOQuery1.FieldValues['deparment']); next; end;end;
展开
2个回答
展开全部
点击combox显示数据,不是用Change的,是用OnEnter的;你把你的代码改成:
procedure TForm1.ComboBox1Enter(Sender:TObject);
begin
combobox1.items.clear;
with Adoquery1 do
begin
close;
sql.clear;
sql.add('select department from codes');
open;
end;
while not AdoQuery1.eof do
begin
ComboBox1.items.add(AdoQuery1.fieldvalues['deparment']);
QdoQuery1.next;
end;
end;
procedure TForm1.ComboBox1Enter(Sender:TObject);
begin
combobox1.items.clear;
with Adoquery1 do
begin
close;
sql.clear;
sql.add('select department from codes');
open;
end;
while not AdoQuery1.eof do
begin
ComboBox1.items.add(AdoQuery1.fieldvalues['deparment']);
QdoQuery1.next;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询