你应该这样: Query1.First; ComboBox1.Text:=Query1.fieldbyname('FieldName').asstring; while not Query1.Eof do begin ComboBox1.Items.Add(Query1.fieldbyname('FieldName').asstring); Query1.Next; end; 行了吧!
同意: V_Lucky(Lucky) 初始化时 Query1.First; ComboBox1.items.clear; while not Query1.Eof do begin ComboBox1.Items.Add(Query1.fieldbyname('FieldName').asstring); Query1.Next; end; if combobox1.items.count > 0 then combobox1.itemindex := 0;用户选择后只要读取combobox1.itemindex 就可以了。 combobox1.items[combobox1.itemindex ]就是用户选择的。应该就是这样实现的,如果理解有误,那还是把你的代码写出来看看。
var s: string; begin s := Query1.fieldbyname('FieldName').asstring; ComboBox1.Text:=Query1.fieldbyname('FieldName').asstring; ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(s); end;
Query1.First;
ComboBox1.Text:=Query1.fieldbyname('FieldName').asstring;
while not Query1.Eof do
begin
ComboBox1.Items.Add(Query1.fieldbyname('FieldName').asstring);
Query1.Next;
end;
行了吧!
这句负不了值
初始化时
Query1.First;
ComboBox1.items.clear;
while not Query1.Eof do
begin
ComboBox1.Items.Add(Query1.fieldbyname('FieldName').asstring);
Query1.Next;
end;
if combobox1.items.count > 0 then
combobox1.itemindex := 0;用户选择后只要读取combobox1.itemindex 就可以了。
combobox1.items[combobox1.itemindex ]就是用户选择的。应该就是这样实现的,如果理解有误,那还是把你的代码写出来看看。
s: string;
begin
s := Query1.fieldbyname('FieldName').asstring;
ComboBox1.Text:=Query1.fieldbyname('FieldName').asstring;
ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(s);
end;
ComboBox1.Items.IndexOf(Query1.fieldbyname('FieldName').asstring);
吧