在DBGrid中用代码实现按回车键跳到下一格的方法

procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then   //回車後跳到下一格
  begin
    with TDBGrid(ActiveControl) do
    if SelectedIndex < (FieldCount -1) then
      SelectedIndex := SelectedIndex + 1
    else
    begin
      DBGrid1.DataSource.DataSet.Append;
      SelectedIndex := 0;
    end;
  end;
end;

示例:

 if Key = 13 then //回車後跳到下一格
    with TDbgrideh(ActiveControl) do
    begin
      if Selectedindex < (FieldCount - 1) then
        Selectedindex := Selectedindex + 1
      else
      begin
        dbgrideh.DataSource.DataSet.Next;
        Selectedindex := 0;
      end
    end;
好的代码像粥一样,都是用时间熬出来的
原文地址:https://www.cnblogs.com/jijm123/p/13983071.html