首页 > 数据库技术 > 详细

TDBGrid中用Enter仿真Tab键盘

时间:2020-10-04 20:02:54      阅读:45      评论:0      收藏:0      [点我收藏+]

procedure TForm1.FormKeyPress(Sender: TObject; var Key: 
Char);
begin
  if Key = #13 then //如果是一个Enter键盘
  begin
    if not (ActiveControl is TDBGrid) then  //如果当前的控件不是TDBGrid
    begin 
       Key := #0; 
       Perform(WM_NEXTDLGCTL, 0, 0); { move to next control }
    end
    else if (ActiveControl is TDBGrid) then //在TDBGrid中
    begin
       with TDBGrid(ActiveControl) do
       begin
         if selectedindex < (fieldcount -1) then //如果不是最后一个字段
            selectedindex := selectedindex +1
         else
            selectedindex := 0;
       end;
   end;
end; 
end;

TDBGrid中用Enter仿真Tab键盘

原文:https://www.cnblogs.com/jijm123/p/13767473.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!