SelectNext(ActiveControl, False, True);

解决方案 »

  1.   

    if Key = #13 then
      Perform(WM_NEXTDLGCTL, 0, 0)
      

  2.   

    检查一下不同的panel中的控件各有一套tab order.
      

  3.   

    //==============================================================================
    //在‘DBGrid’中‘空格’移到下一列**********************************************
    //在‘Form’中‘回车’、‘下箭头’进入下一个控制********************************
    //在‘Form’中‘上箭头’进入上一个控制******************************************
    //==============================================================================
    procedure WindowKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    begin
      //============================================================================
      //1.空格键:在‘DBGrid’中移到下一列*******************************************
      //============================================================================
      if (Key=VK_SPACE) and ((Sender as TForm).ActiveControl is TDBGrid) then
         with TDBGrid((Sender as TForm).ActiveControl) do
           if SelectedIndex<(FieldCount-1)
           then SelectedIndex := SelectedIndex + 1//increment the field
           else begin
                  SelectedIndex := 0;
                  if not TDBGrid((Sender as TForm).ActiveControl).DataSource.DataSet.Eof
                  then TDBGrid((Sender as TForm).ActiveControl).DataSource.DataSet.Next
                  else TDBGrid((Sender as TForm).ActiveControl).DataSource.DataSet.First;
                end;
      //============================================================================
      //2.回车键:在‘Form’中进入下一个控制*****************************************
      //============================================================================
      if Key=VK_RETURN then
         if not ((Sender as TForm).ActiveControl is TCustomGrid) then//if not on a TDBGrid
         begin
           Key := Word(0);//eat enter key
           (Sender as TForm).Perform(WM_NEXTDLGCTL, 0, 0);//move to next control
         end;
      //============================================================================
      //3.下箭头:在‘Form’中进入下一个控制*****************************************
      //============================================================================
      if Key=VK_DOWN then
         if  not ((Sender as TForm).ActiveControl is TDBLookupControl)
         and not ((Sender as TForm).ActiveControl is TCustomGrid)
         and not ((Sender as TForm).ActiveControl is TCustomListBox)
         and not ((Sender as TForm).ActiveControl is TCustomComboBox)
         and not ((Sender as TForm).ActiveControl is TCustomTreeView)
         then begin
                Key := Word(0);//eat down key
                (Sender as TForm).Perform(WM_NEXTDLGCTL, 0, 0);//move to next control
              end;
      //============================================================================
      //4.上箭头:在‘Form’中进入上一个控制*****************************************
      //============================================================================
      if Key=VK_UP then
         if  not ((Sender as TForm).ActiveControl is TDBLookupControl)
         and not ((Sender as TForm).ActiveControl is TCustomGrid)
         and not ((Sender as TForm).ActiveControl is TCustomListBox)
         and not ((Sender as TForm).ActiveControl is TCustomComboBox)
         and not ((Sender as TForm).ActiveControl is TCustomTreeView)
         then begin
                Key := Word(0);//eat up key
                (Sender as TForm).Perform(WM_NEXTDLGCTL, -1, 0);//move to back control
              end;
    end;
      

  4.   

    将FORM的KeyPreview设为True,然后在FORM的KeyPress中加
    if Key = #13 then
      Perform(WM_NEXTDLGCTL, 0, 0)
      

  5.   

    将FORM的KeyPreview设为True,然后在FORM的KeyPress中加
    if Key = #13 then
      Perform(WM_NEXTDLGCTL, 0, 0)
      

  6.   

    if (Key = #13) then
         begin
    Key := #0; { Eat the enter key }
    Perform(WM_NEXTDLGCTL, 0, 0);
         end;