procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = vk_Left) or (Key = vk_up) or (Key = vk_Right) or (Key = vk_Down) then
Key := ord(#0);
end;
Shift: TShiftState);
begin
if (Key = vk_Left) or (Key = vk_up) or (Key = vk_Right) or (Key = vk_Down) then
Key := ord(#0);
end;
解决方案 »
- 快速拆分字符串
- 记那对住在我隔壁储藏室的大学刚毕业的小夫妻 看看吧 我们.....
- 用CreateFile创建文件后,如何立刻关闭它?万分紧急,在线等!!
- ◆◆◇◇★★★★★★★请问如何把一个dll文件当作资源文件放入程序中★★★★★★◇◇◆◆
- beyondtkl(大龙驹<梦.考古广告人生>) 和 DaSaint(齐天大圣) 两位,接分
- cxGrid控件怎么手动往TcxGridTableView里增加记录?
- 建议Delphi程序员留下MSN号 方便交流
- 用程序创建数据库...
- 有没有办法减少SQL Server日志的大小?
- 在北京用那个语言最多?
- 请问在一个函数中可以再定义一个函数吗?
- 呵呵,再过几分钟就是偶的生日,送分同庆!!!!(sundayboys)
Shift: TShiftState);
begin
if (Key=VK_Left) or (Key=VK_up) or (Key=VK_Right) or (Key=VK_Down) then
Key := 0;
end;
Shift: TShiftState);
begin
case Key of
VK_LEFT, VK_RIGHT: if not TDBGrid(Sender).EditorMode then Key := 0;
VK_UP, VK_DOWN: Key := 0;
end;
end;
Shift: TShiftState);
begin
if (Key=VK_Left) or (Key=VK_up) or (Key=VK_Right) or (Key=VK_Down) then
Key := 0;
end;
以上诸位老兄的方法都很好,在KeyPress事件中,无法捕获方向键,只能在KeyDown中!
procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key in[037,038,039,040] then
begin
showmessage('您不能进行这项操作');
key:=0;
end;end;