with query1 do
begin
  ....
  query1.open;
  with not eof do
  begin
    combobox1.items.add(inttostr(query1.fieldbyname('code').asinteger));//如果是字符类型的combobox1.items.add(query1.fieldbyname('code').asstring)
    next;
  end;
end;

解决方案 »

  1.   

    ComboBox1.Items.Clear;with Table1 do
    begin
      First;
      while not Eof do
      begin
        ComboBox1.Items.Add(IntToStr(FieldByName('code').AsInteger));
        Next;
      end;
    end;
      

  2.   

    procedure TForm1.ComboBox1DropDown(Sender: TObject);
    begincombobox1.items.clear;
    with query1 do
    begin
      close;
      sql.clear;
      sql.add(' select Code from table ');
      Open;
      while not eof do
      begin
       combobox1.items.add(inttostr(fieldbyanem('code').asinteger));
       Next;
      end;
    end;
    end;
      

  3.   

    with query1 do
    begin
      ....
      query1.open;
      with not eof do
      begin
        combobox1.items.add(inttostr(query1.fieldbyname('code').asinteger));//如果是字符类型的combobox1.items.add(query1.fieldbyname('code').asstring)
        next;
      end;
    end;
    类似于这样的问题,楼主是否能快点结呢,因为答案已经贴出?
      

  4.   

    有一个很好的控件在Data Controls面板上:
    TDBLookupListBox
    只要指定相关属性即可.
      

  5.   

    错了应该是:TDBLookupComboBox
    属性KeyField:  指定键值
    属性ListField: 指定要显视的值
      

  6.   

    用TDBLookupListBox不是很灵活还是这么将就着用了吧不过,你这样的显示出来的可能是id 如果想显示display 程序里边对应id的话建议用动态数组建立一一对应关系
      

  7.   

    不过,你这样的显示出来的可能是id 如果想显示display 程序里边对应id的话建议用动态数组建立一一对应关系:
    设置一下keyfield,listfield,和listdatasource就可以了
    datafield和datasource为空
      

  8.   

    不是有个ComboBox的数据库控件吗干什么不用呢。
      

  9.   

    Up!Up!Up!Up!Up!---------------------------
    行行好,帮帮我这可怜的人吧