如果条件达到后,edit2.setfocus;

解决方案 »

  1.   

    在FORM的onkeydown: if (key==13) then
     edit2.setfocus;
      

  2.   

    设置From的KeyPreview的属性为True,在From的KeyPress事件中写入:如
    procedure TfrmLogin.FormKeyPress(Sender: TObject; var Key: Char);
    begin
      if key = #13 then
      begin
        Key := #0;
        PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
      end; 
    end;
      

  3.   

    最好的办法: 在Form的Onkeypress 中写:
     
     if Key =#13 then
    begin
         key := #0;
         SelectNext(ActiveControl, true, true);
    end;这样如果有多个Edit,只写这一个就行,不过要记得把 Form的Keypreview设为True!
      

  4.   

    在Form的Onkeypress中写,有点小问题,如果Form中有Memo控件或Button上也许就不好使了
      

  5.   

    if #13=Key then
            begin
            Self.FindNextControl(Sender as TwinControl,True,True,False).SetFocus;
            end;
      

  6.   

    在OnKeyPress中处理,如果用SetFocus,则每个Edit都要写XXX.SetFocus,太烦了。
        if #13=Key then
            begin
            Self.FindNextControl(Sender as TwinControl,True,True,False).SetFocus;
            end;
    就省事了。
      

  7.   

    在OnKeyPress中处理,如果用SetFocus,则每个Edit都要写XXX.SetFocus,太烦了。
        if #13=Key then
            begin
            Self.FindNextControl(Sender as TwinControl,True,True,False).SetFocus;
            end;
    就省事了。当然,TABORDER要设定好。
      

  8.   

    procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
    begin
        case key of
        #13  :
           if active then Perform(WM_NEXTDLGCTL, 0, 0);
        end;    //endcase
    end;这样就回把回车当做了tab键处理
      

  9.   

    在OnKeyPress中处理,如果直接用对象的SetFocus,则每个Edit都要写XXX.SetFocus,太烦了。
    if #13=Key then
        begin
        Self.FindNextControl(Sender as TwinControl,True,True,False).SetFocus;
        end;
    就省事通用多了了。当然,TABORDER要设定好。