1):双击dbgrid加入全部字段,选中某一字段,它有一属性picklist属性中输入你要选择的内容 2):画: 在dbgrid的drawdatacell事件中 if (gdfocused in state)then begin if(field.fieldname=dbcombobox1.datafield)then begin dbcombobox1.left:=rect.left+dbgrid1.left; dbcombobox1.top:=rect.top+dbgrid1.top; dbcombobox1.width:=rect.right-rect.left; dbcombobox1.height:=rect.bottom-rect.top; dbcombobox1.visible:=true; end; end; 在dbgrid的colExit事件中写 if dbgrid1.selectedfield.fieldname=dbcombobox1.datafield then begin dbcombobox1.visible:=false; end; 在dbgrid的keypress事件中写 if(key<>chr(9)) then begin if(dbgrid1.selectedfield.fieldname=dbcombobox1.datafield)then begin dbcombobox1.setfocus; sendmessage(dbcombobox1.handle,wm_char,word(key),0); end; end;
2):画:
在dbgrid的drawdatacell事件中
if (gdfocused in state)then
begin
if(field.fieldname=dbcombobox1.datafield)then
begin
dbcombobox1.left:=rect.left+dbgrid1.left;
dbcombobox1.top:=rect.top+dbgrid1.top;
dbcombobox1.width:=rect.right-rect.left;
dbcombobox1.height:=rect.bottom-rect.top;
dbcombobox1.visible:=true;
end;
end;
在dbgrid的colExit事件中写
if dbgrid1.selectedfield.fieldname=dbcombobox1.datafield then
begin
dbcombobox1.visible:=false;
end;
在dbgrid的keypress事件中写
if(key<>chr(9)) then
begin
if(dbgrid1.selectedfield.fieldname=dbcombobox1.datafield)then
begin
dbcombobox1.setfocus;
sendmessage(dbcombobox1.handle,wm_char,word(key),0);
end;
end;