我想在dbgrid中点某一行的某个字段出现一个下拉框,下拉框中的内容来自其它数据集中的数据。
谢谢,在线等待。

解决方案 »

  1.   

    with dbgrid_data_mx  do
           for j:=1 to FieldCount do
             begin
             if columns[j].FieldName ='peij_dw' then
             begin
              columns[j].PickList.Clear;
              for i:=1 to recordcount do
               begin
               columns[j].PickList.Add(fieldbyname('danwei_lc').asstring);
               next;
               end;
                break;
             end;
             end;
           end;//for
      

  2.   

    用eh控件吧 把数据库中的某个字段的picklist加上数据库里某个表中的数据
      

  3.   

    如果要自己编写程序,就需要用到PickList了,或者用其他控件也可以,直接使用Lookup
      

  4.   

    qingke21(清柯) ( )
    这段代码放在哪个位置上呀?
      

  5.   

    回复人: jabmoon(刺月) 
    PickList 这个我用过了,用sql 语句没有用呀。
      

  6.   

    用ADOQUery,设置LookUp字段,直接在界面上搞搞就可以了
      

  7.   

    用dblookupcombobox连接要显示的数据源
    procedure Tfrom1.DBGridEh1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumnEh;
      State: TGridDrawState);
    begin  with Column do
      begin
         if (gdfocused in state) then
         begin
            with DBLookupComboBox_xm do
            if (FieldName=DataField) then
            begin
               Left:=Rect.Left+DBGridEh_shipment.left;
               top:=rect.top+DBGridEh_shipment.top;
               width:=rect.right-rect.left+2;
               height:=rect.bottom+DBGridEh_shipment.top;
               visible:=true;
               setfocus;//获得焦点
            end;
         end;
      end;
    end;
    procedure Tform1.DBGridEh1ColExit(Sender: TObject);
    var i:integer;
    begin
      for i:=0 to DBGridEh1.Columns.Count-1 do
      if DBGridEh_shipment.Columns[i].FieldName='xm' then
         DBLookupComboBox_dh.Visible:=false;
    end;
      

  8.   

    PickList和lookup字段都不能编辑,郁闷...!