比如现在的焦点在第一行第一列,当第一行第一列输入完毕后,焦点自动跳到第一行第二列

解决方案 »

  1.   

    怎样知道你输入完毕呢!
    焦点自动跳转不是问题,
    关键是不知道你什么时候完毕!
    dbgrid.DataSource.DataSet.Next;
    中间还要考虑Post和Edit操作!
      

  2.   

    with dg.SelectedField do
    begin
      SelectedIndex := Selectedindex + 1;
    end;
      

  3.   

    在DBGrid的OnKeyDown事件写代码:procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      //按回车就跳到下一行
      if Key = VK_RETURN then
        DBGrid1.SelectedIndex := DBGrid1.SelectedIndex + 1;
    end;
      

  4.   

    在blazingfire的基础上添加点东西,就可以实现按回车键后焦点自动往下跳了,而且可以跳到下一行。(感谢一下blazingfire)
    procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if Key = VK_RETURN then
      begin
        if DBGrid1.SelectedIndex <> (DBGrid1.FieldCount-1) then
        begin
          DBGrid1.SelectedIndex := DBGrid1.SelectedIndex + 1;
        end
        else begin
          DBGrid1.SelectedIndex := 0;
          table1.Next;
        end;
      end;
    end;
      

  5.   


    能新建记录的代码:
    procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
      if Key = VK_RETURN then
      begin
        if DBGrid1.SelectedIndex <> (DBGrid1.FieldCount-1) then
        begin
          DBGrid1.SelectedIndex := DBGrid1.SelectedIndex + 1;
        end
        else  begin
          DBGrid1.SelectedIndex := 0;
          table1.Next;
        end;
        if table1.Eof and (DBGrid1.SelectedIndex = (DBGrid1.FieldCount-2)) then
        begin
          table1.Append;
          table1.Edit;
        end;
      end;
    end;
    反正在Delphi7环境下通过了,不知道是不是楼主想要的功能。