在keypress事件里
if (dbgrid1.SelectedIndex = 0)
or (dbgrid1.SelectedIndex = 1)
or (ddbgrid1.SelectedIndex = 2) then
begin
if not (key in [#13]) then //回车键保留,其它屏蔽
key:=#0;
end;
同时需要在keydown里屏蔽delete
if (dbgrid1.SelectedIndex = 0)
or (dbgrid1.SelectedIndex = 1)
or (ddbgrid1.SelectedIndex = 2) then
begin
if Key = VK_Delete then
key:=#0;
end;