在dbgrid中的字段中实现有下拉框,在原始录入中有的字段值要规范, 
想通过下拉框怎样做?

解决方案 »

  1.   

    picklist
    自己到help里查查吧
    dbgrid.picklist.add();  etc
      

  2.   

    和dbcombobox复合,我以前做过,不过不适合中国人的习惯啊
      

  3.   

    1,用picklist
    2,在dbgrid中画一个啊在drawdatacell事件中
    if (gdfocused in state) then
     begin
      if (field.fieldname=dbcombobox.datafield) then
      begin
      dbcombobox1.left:=rect.left+dbgrid1.left
      dbcombobox1.top:=rect.top+dbgrid1.top;
      dbcombobox1.width:=rect.right-rect.left;
      dbcombobox1.height:=rect.botton-rect.top;
      dbcombobox1.visible:=true;
    end;
    end;
    在colexit事件中
    if dbgrid1.selectedfield.fieldname=dbcombobox1.datafield then
     dbcombobox1.visible:=false;
    在keypress事件中
    if (key<>chr(9)) then
     begin
     if(dbgrid1.selectedfield.fieldname=dbcombobo1.datafield) then
    begin
     dbcombobox1.setfocus;
    sendMessage(dbcombobox1.handle,wm_char,word(key),0);
    end;
    end; 
    3,使用api函数
    api函数为:drawframecontrol()
      

  4.   

    1,picklist 手工输入 当然也可以在程序中动态的添加2,DBGRIDEH 第三方控件,可以直接关联数据库字段显示一开始就可以设置完毕