在 DBGrid 中如何让回车变为光标右移动

时间:2020-05-16 17:19:05   收藏:0   阅读:85

在Form.OnKeyPress事件中写如下代码:

  if Key = #13 then 
  if ActiveControl = DBGrid1 then begin 
    TDBGrid(ActiveControl).SelectedIndex := TDBGrid(ActiveControl).SelectedIndex + 1; 
    Key := #0; 
end; 

有2点需要注意:
  1.当光标达到DBGird最右列的时候,再按回车,光标还会停留在原地。
  2.Key := #0

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!