怎样解决回车、Tab键在DBGrid表单元格的移动问题?

时间:2020-11-20 11:49:19   收藏:0   阅读:18
procedure Tfrm_rk.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then { 判断是按执行键}
    if not (ActiveControl is TDbgrid) Then
      Begin { 不是在TDbgrid控件内}
        key:=#0;
        perform(WM_NEXTDLGCTL,0,0);{移动到下一个控件}
    end else
    if (ActiveControl is TDbgrid) Then{是在 TDbgrid 控件内}
    begin
      With TDbgrid(ActiveControl) Do
        if Selectedindex<(FieldCount-1) then
          Selectedindex:=Selectedindex+1{ 移动到下一字段}
        else Selectedindex:=0;
    end;
end;

 

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