虽然dbgrideh里有设置,但是如果设置了,在keypress里就收不到回车消息了。
因为想在按下回车后做一些事再跳到下一格,但是下面代码却没办法实现。
  if Key = #13 then
  begin    SendMessage(StockPlanList.Handle,WM_NEXTDLGCTL,0,0);
  end;

解决方案 »

  1.   

    没用过, 不过总体上就是keypress里处理
      

  2.   

    这样就行:
    procedure TForm1.dbgPrintListKeyPress(Sender: TObject; var Key: Char);
    begin
      if Ord(Key) = VK_RETURN then
        if ActiveControl = dbgPrintList then
        begin
          TDBGrid(ActiveControl).SelectedIndex := TDBGrid(ActiveControl).SelectedIndex + 1;
          Key := #0;
        end;
    end;
      

  3.   

    Enter键代替Tab键.   procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);   begin     if Key = #13 then     if ActiveControl = DBGrid1 then     begin        TDBGrid(ActiveControl).SelectedIndex := TDBGrid(ActiveControl).SelectedIndex + 1;        Key := #0;     end;   end;
      

  4.   

    没用过这个,但是应该是在
    procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);中
    写代码,
    if DBGrid1.DataSource1.DataSet1.acive then 
    begin
      if Key = #13 then
      DBGrid1.DataSource1.DataSet1.next;
      判断当到了最后条时,跳到第一条,或者你做其他处理;
    end;
      

  5.   

    同意 Enter键代替Tab键安装键盘hook可实现enter代替tab给出信箱给你代码
      

  6.   

    楼上的,用这样的语句
    TDBGrid(ActiveControl).SelectedIndex := TDBGrid(ActiveControl).SelectedIndex + 1;
    能达到效果,但是还有一个小问题,就是在最后一列的时候,按下enter,不会跳到下一行的第一列!
      

  7.   

    DELPHI里面有没有类似VB中的SENDKEY函数,如果有的话,那就好办多了。
    学习
      

  8.   

    procedure TFrmDepotTOutGl.FormKeyPress(Sender: TObject; var Key: Char);
    begin
      if (key = #13)And(not (ActiveControl is TMemo)) then
      if not (ActiveControl is TDbGrid) then
      begin
        Key := #0;
        Perform(Wm_NextDlgCtl,0,0);
      end else
        if (ActiveControl is TDbGrid) then
        begin
          With TDbGrid(ActiveControl) do
          if SelectedIndex < (FieldCount - 1) then
            SelectedIndex := SelectedIndex + 1
          else
            SelectedIndex := 0;
        end;
    end;
      

  9.   

    KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if (Key = 13) or (Key = 9) then
         PostMessage(Self.Handle, WM_KEYDOWN, VK_TAB, 0);
    end
      

  10.   

    SunKinXing(飞火流星) 
    你那个代码只是在最后一列按回车是跳到本行的第一列,并不是新起一行的第一列