假如我的窗体上有N个文本框,我录入第一个文本框后回车,怎么控制跳到第二个文本框,。

解决方案 »

  1.   

    假如有Edit1和Edit2:
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if Key=#13 then
        Edit2.SetFocus;
    end;
      

  2.   

    大哥,我觉得你这种方法写代码好象很累呀,我的一个窗体N个文本框,能不能根据TAB的顺序自动获取焦点,代码省了很多,只是我不会写,谁会的话告诉我呀
      

  3.   

    在keypress事件里
    if key = #13 then
    begin
      key := #0;
        SelectNext(ActiveControl,true,true);
    end;//当然前提你要设置好TAP.
      

  4.   

    在form.onshortcut
      if msg.CharCode = 13 then
        perform(WM_NEXTDLGCTL, 0, 0);
      

  5.   

    提前按顺序设置好你的edit的taborder
      

  6.   

    查一查共享事件处理函数的应用.(sender :Tobject)
      

  7.   

    1.设置好Tab.2.窗体的属性:KeyPreview设置为True.3.窗体的OnKeyPress事件中写:if Key=#13 then
      SelectNext(ActiveControl,True,True);
      

  8.   

    其实用1楼的那个就可以了,要是觉得烦可用 procedure SetFocusNext(var Key:char; Edit1: TEdit);
    begin
      if Key=#13 then
        Edit1.SetFocus;
    end;
    再调用,呵呵