我现在有5个文本框,从第一个开始到下一个不用鼠标和(Tab键)要用“回车键”(Enter)换到下一个,不知道如何设置属性或代码,请高手指点一二啊

解决方案 »

  1.   

    IF KEY=#13 THEN SELECT ACTIVECONTROL(参数)
      

  2.   

    KeyPress事件
     if key = #13 then
     要得到焦点的控件 := ActiveControl;
      

  3.   

    方法1 
     在每一个edit.press事件里写
    if key=#13 then 
    begin
    edit2.setfocus;
    exit;
    end;方法2 可以让每个edti组件引用这一个事件 if key=#13 then
      begin
        perform(cm_dialogkey,vk_tab,0); //焦点按照Taborder的顺序下移
        exit;
      end;
      

  4.   

    在每个OnkeyPress事件里加入,
      if Key=#13 then
        Edit2.SetFocus;
      

  5.   

    yuzhantao(找不到女朋友,只好养条狗)的第二种方法比较好,适合用于文本框比较多的时候.
      

  6.   

    在OnKeyDown事件中写如下代码:if Key=VK_RETURN then
      SelectNext(ActiveControl,true,true)
      

  7.   

    在每个OnkeyPress事件里加入
    if key =#13 then
    begin
      key = #0;
      selectnext(activecontrol,true,true);
    end;
      

  8.   

    if key = #13 then
      begin
        key:=#0;
        Self.ActiveControl := FindNextControl((Sender as wincontrol),true,true,false);
      end;
      

  9.   

    回车替Tab下移控件 
    需要用回车键代替TAB键下移一个控件时,把KeyPress设为True,加入下列代码拦截击键:
    Procedure TForm1.FormKeyPress(Sender:Tobject;Var Key:Char);
    Begin
     if key=#13 then { 判断是按执行键}
     if not (ActiveControl is TDbgrid) Then
     Begin { 不是在TDbgrid控件内}
      key:=#0;
      perform(WM_NEXTDLGCTL,0,0);{移动到下一个控件}
     end else
     if (ActiveControl is TDbgrid) Then{是在 TDbgrid 控件内}
     begin
      With TDbgrid(ActiveControl) Do
      if Selectedindex<(FieldCount-1) then
      Selectedindex:=Selectedindex+1{ 移动到下一字段}
      else Selectedindex:=0;
     end;
    End;
      

  10.   

    如果是n个edit控件,也可以像 huanyi(残荷淡月) 那樣做麽?
      

  11.   

    If Key=#13 then
    Begin
      Key:=#0;
      Perform(wm_nextdlgctl,0,0);
    End;
      

  12.   

    If Key=#13 then
    Begin
    Key:=#0;
    Perform(wm_nextdlgctl,0,0);
    End;