你可以在窗口的oncreate事件中添加DBComboBox1的Item。Query1:'select distinc field1 from t1'DBComboBox1.Items.Clear;//记得先清楚 循环添加DBComboBox1.Items.Add('query1的field1');
With query1 do begin close; sql.clear; sql.add('select distinc field1 from t1'); open; combobox1.items.clear; while not eof do begin combobox1.items.add(adoquery1.fieldbyname('field1').asstring); adoquery1.next; end; combobox1.itemindex:=0; end;
我把上面的代码写在oncreat事件中,但是编译时 combobox1.items.clear; combobox1.items.add(adoquery1.fieldbyname('field1').asstring); combobox1.itemindex:=0; 这三行有错,提示combobox1 有问题,提示内容为: "Record, object,or class type required" 请问怎么解决。
循环添加DBComboBox1.Items.Add('query1的field1');
begin
close;
sql.clear;
sql.add('select distinc field1 from t1');
open;
combobox1.items.clear;
while not eof do
begin
combobox1.items.add(adoquery1.fieldbyname('field1').asstring);
adoquery1.next;
end;
combobox1.itemindex:=0;
end;
combobox1.items.clear;
combobox1.items.add(adoquery1.fieldbyname('field1').asstring);
combobox1.itemindex:=0;
这三行有错,提示combobox1 有问题,提示内容为:
"Record, object,or class type required"
请问怎么解决。
我在两层中试过了
是ENterprise版的,请问这又没有影响。