我在DBGRID编辑状态下想按回车键让光标从记录的当前位置聚焦到该记录的下一个单元格,就如按键盘的右键一样,如何实现?

解决方案 »

  1.   

    procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
    begin
        if key <> #13 then exit;
        //模拟TAB键
        KeyBd_Event(VK_TAB,0,0,0);
        KeyBd_Event(VK_TAB,0,2,0);
    end;
      

  2.   

    没有效果,在DBGRID中TAB键无法使用
      

  3.   

    if (Key=VK_SPACE) and (WinControl is TDBGrid) then
         with TDBGrid(WinControl) do
           if SelectedIndex<(FieldCount-1)
           then SelectedIndex := SelectedIndex + 1//increment the field
           else begin
                  SelectedIndex := 0;
                  if not TDBGrid(WinControl).DataSource.DataSet.Eof
                  then TDBGrid(WinControl).DataSource.DataSet.Next
                  else TDBGrid(WinControl).DataSource.DataSet.First;
                end;
      

  4.   

    DBGrid的Optoins属性的dgTabs要设为True
      

  5.   

    sysu你的方法还是不成,我不知道你试过没有,我这边不成