dbcombobox.datasource:=datasource1;
dbcombobox.datafield:=字段名;

解决方案 »

  1.   

    这是delphi一贯的做法,向我以前用惯了vfp,也很不适应。
    这段程序应该自己写。
    with dm.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既可以显示当前的字段的值,也可以运行时下拉有其他的纪录