这是delphi一贯的做法,向我以前用惯了vfp,也很不适应。
这段程序应该自己写。
with ADOQuery1 do
  begin
   active:=false;
   sql.Clear;
   sql.Add('select id  from table1);
   open;
   if  RecordCount>0 then
   begin
   first;
   for i:=0 to RecordCount-1 do
      begin
      str:=Fields.Fields[0].Value;
      dbcombobox1.Items.add(str);
      Next;
      end;
   end;
end;
str为字符型,在var 中定义
var 
str:string;这样做之后,
如果数据源也指定,在程序中dbcombobox1既可以显示当前的字段的值,也可以运行时下拉有其他的纪录

解决方案 »

  1.   

    也就是说我用combobox的datafield绑定table中的一个字段的方法不行吗?难道一定要用query控件然后自已写代码?
      

  2.   

    对!Delphi中只能通过代码实现。
    类似的还有DBGrid中的下拉框。
      

  3.   

    这样做也可以。
    with talble1 do
      begin
       active:=false;
       open;
       if  RecordCount>0 then
       begin
       first;
       while not table1 eof do 
          begin
                dbcombobox1.Items.add(Fields.Fields[n].Value);//n指代所用的字段,从0开始。
                next;
          end;
       end;
    end;
       如果用作动态处理,可以动态给talble1指定链接的表。
      

  4.   

    这样做也可以。
    with talble1 do
      begin
       active:=false;
       open;
       if  RecordCount>0 then
       begin
       first;
       while not table1 eof do 
          begin
                dbcombobox1.Items.add(Fields.Fields[n].Value);//n指代所用的字段,从0开始。
                next;
          end;
       end;
    end;
       如果用作动态处理,可以动态给talble1指定链接的表。
      

  5.   

    with adoquery1 do
        begin
          close;
          sql.Clear;
          sql.Add('select number from xsgl..xsjbxx');
          open;
          first;
          while not eof do
            begin
              dbcombobox1.Items.Add(adoquery1.fieldbyname('number').asstring);
              next;
          end;
       end;
      

  6.   

    with adoquery1 do
        begin
          close;
          sql.Clear;
          sql.Add('select number from xsgl..xsjbxx');
          open;
          first;
          while not eof do
            begin
              dbcombobox1.Items.Add(adoquery1.fieldbyname('number').asstring);
              next;
          end;
       end;
      

  7.   

    我刚由vb转过来学delphi十分不适应,别人说它的控件好用,我到现在还体会不到。不知大家对此有什么看法?
      还有就是delphi中的函数名等标识符的名称太长了,不好记,帮助系统也有大好,明显的举个例子:with...do....起码VB中就可以用一个'。'号自动引出属性列表窗;VB的explicit语句又可以变量的大小写得以统一看起来方便。不知大伙对delphi的感受如何,说来大家讨论一下吧!
      

  8.   

    我试了一下,单用TDBLookupComboBox不写代码好像也不行啊!
      

  9.   

    (Blank)你的方法我已经实现了,谢谢。但是记录只显示在combobox的下拉列表中,它的edit框中并不出现选中的记录信息,这又如何实现呢?
      

  10.   

    我用的是IP3000中的twwDBLookuoComboBox,其他的好像都不行
      

  11.   

    用TDBLookupComboBox不用写代码,只要对应的字段有值就能显示出来,最好是对应此字段建一个新表,作为数据字典