在form中放一个dbcombobox 值为不可见
响应dbgrid的ondrawdatacell事件
if (gbfocused in State) then
begin
dbcombobox1.Left:=rect.left+dbgrid1.left;
dbcombobox1.Top:=rect.top+dbgrid1.top;
dbcombobox1.width:=rect.Right-dbgrid1.left;
dbcombobox1.Height:=rect.bottom-dbgrid1.Top;
dbcombobox1.Visible:=True;
end;
响应dbgrid的onColExit事件
begin
dbcombobox1.Visible:=False;
end;
响应dbgrid的onKeyPress事件
begin
if (key<>chr(9)) then
if (dbgrid1.SelectedField.FieldName=dbcombobox.Datafield) then
begin
dbcombobox.setfocus;
sendmessage(dbcombobox1.handle,WM_CHAR,word(key),0);
end;
dbgrid的popupmenu属性