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

在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

posted on 2020-05-16 15:49  癫狂编程  阅读(151)  评论(0编辑  收藏  举报

导航

好的代码像粥一样,都是用时间熬出来的