//按下ENTER键代替TAB键if key=#13 then                             
begin
 key:=#10;
 selectnext(activecontrol,true,true);
end

解决方案 »

  1.   

    你先在一个edit的onkeypress里双击,出现一个procdeure
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
    //按下ENTER键代替TAB键
    if key=#13 then
    begin
    key:=#10;
    selectnext(activecontrol,true,true);
    end
    end;然后在别的edit的属性里面就能找到这个,procedure了,这样就可以引用了
      

  2.   

    所有的edit都用同一个,在events的下拉列表里面选择就可以了
      

  3.   

    unit CommLib;interface
    uses CommDeclare, Classes, TypInfo;//過濾在編輯框的輸入字符
    procedure FilterInput(EditList: array of TComponent;
      fiType: TFIType);//檢測某個控件是否存在某個屬性
    function HasProperty(aComponent: TComponent;const PropName: string): Boolean;implementation//過濾在編輯框的輸入字符
    procedure FilterInput(EditList: array of TComponent;
      fiType: TFIType);
      procedure NoSpaceKeyPress(self: TObject;Sender: TObject; var Key: Char);
      begin
        if Key=#32 then
          Key := #0;
      end;
      procedure IntegerKeyPress(self: TObject;Sender: TObject; var Key: Char);
      begin
        if not (Sender is TComponent) then
          Exit;
        if not (Key in ['0'..'9','-',#8,#46,#13]) then
          Key := #0;
        if Key='-' then
          if HasProperty(TComponent(Sender),'Text') then
            if Length(GetStrProp(Sender,'Text'))>0 then
              Key := #0;
      end;
      procedure NoSignIntKeyPress(self: TObject;Sender: TObject; var Key: Char);
      begin
        if not (Key in ['0'..'9',#8,#46,#13]) then
          Key := #0;
      end;
      procedure FloatKeyPress(self: TObject;Sender: TObject; var Key: Char);
      var
        TextValue: string;
      begin
        if not (Sender is TComponent) then
          Exit;
        if not (Key in ['0'..'9','.','-',#8,#46,#13]) then
          Key := #0;    if Key='-' then
          if HasProperty(TComponent(Sender),'Text') then
            if Length(GetStrProp(Sender,'Text'))>0 then
              Key := #0;
        if Key='.' then
          if HasProperty(TComponent(Sender),'Text') then
          begin
            TextValue := GetStrProp(Sender,'Text');
            if Pos('.',TextValue)<>0 then
              Key := #0;
            if Pos('.',TextValue)=1 then
              SetStrProp(Sender,'Text','0.');
          end;
      end;
      procedure NoSignFloatKeyPress(self: TObject;Sender: TObject; var Key: Char);
      var
        TextValue: string;
      begin
        if not (Sender is TComponent) then
          Exit;
        if not (Key in ['0'..'9','.',#8,#46,#13]) then
          Key := #0;    if Key='.' then
          if HasProperty(TComponent(Sender),'Text') then
          begin
            TextValue := GetStrProp(Sender,'Text');
            if Pos('.',TextValue)<>0 then
              Key := #0;
            if Pos('.',TextValue)=1 then
              SetStrProp(Sender,'Text','0.');
          end;
      end;
      procedure DateKeyPress(self: TObject;Sender: TObject; var Key: Char);
      begin
        if not (Key in ['0'..'9','-',#8,#46,#13]) then
          Key := #0;
      end;
      
    var
      aMethod: TMethod;
      iLoop: integer;
    begin
      case fiType of
        fiNoSpace: aMethod.Code := @NoSpaceKeyPress;
        fiInteger: aMethod.Code := @IntegerKeyPress;
        fiNoSignInt: aMethod.Code := @NoSignIntKeyPress;
        fiFloat: aMethod.Code := @FloatKeyPress;
        fiNoSignFloat: aMethod.Code := @NoSignFloatKeyPress;
        fiDate: aMethod.Code := @DateKeyPress;
        else ;
      end;
      aMethod.Data := nil;
      for iLoop := Low(EditList) to High(EditList) do
        SetMethodProp(EditList[iLoop],'OnKeyPress',aMethod);
    end;//檢測某個控件是否存在某個屬性
    function HasProperty(aComponent: TComponent;const PropName: string): Boolean;
    var
      PropInfo: PPropInfo;
    begin
      PropInfo := GetPropInfo(aComponent.ClassInfo,PropName);
      Result := PropInfo<>nil;
    end;end.公共單元,加上
    if key=#13 then                            
    begin 
      key:=#10; 
      selectnext(activecontrol,true,true); 
    end
      

  4.   

    把你的代码写成一个函数,然后在其他窗体生成时,将某些事件只想该函数
    比如keypress,注意参数要一致