dbgrid的picklist:怎样才能禁止输入,只能选择? ( 积分: 50 )

  • 主题发起人 主题发起人 wooiguo
  • 开始时间 开始时间
在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;
 
在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;
 
接受答案了.
 

Similar threads

后退
顶部