怎么遍历一个表的某个字段。然后让它显示在ComboBox控件上。??

解决方案 »

  1.   

    在combobox ondropdown 事件里添加如下代码
    前提是你已经是用adoquery连接到所需要的数据库
    with adoquery do
    begin
      close;
      sql.clear;
      sql.text:='select field from table';
      sql.open;
      first;
      while not eof then
      begin
        combobox.items.add(fieldbyname('field').asstring);
        next;
      end;end;
      

  2.   

    with adoquery do
    begin
      close;
      sql.text:='select field from table';
      open;
      first;
      while not eof then
      begin
        combobox.items.add(fieldbyname('field').asstring);
        next;
      end;end;
    纠正
      

  3.   

    不能在ondropdown中添加上面的代码,如果多打开几次就重复了,在form的oncreate事件中添加代码~!