TDBGrid中用Enter仿真Tab键盘

来源:互联网 发布:angularjs 调用python 编辑:程序博客网 时间:2024/05/21 10:32
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

 

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;
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击