procedure TMainWindow.UserInputKeyPress(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  TempV:shortstring;
begin
  if key=VK_RETURN then    
    begin
      tempv:=userinput.Text;
      ......
      userinput.Clear; 
      userinput.Text:=tempv;
      userinput.SelectAll;
    end;
end;

解决方案 »

  1.   

    不会有什么问题吧
    你在TMEMO的onkeydown事件中用一下
      

  2.   

    Ok,多谢Winsky,(不过还少一句 key:=#0,不然文本就又被删了).
      

  3.   

    在keypress理做,而且把回车键屏蔽,不然字符串被会车覆盖。var
      TempV: string;
    begin
      inherited;
      if key = #13 then    // 为了不清除文本,应如何修改key值?或是根本不行?
        begin
          tempv:=memo1.Text;
          memo1.Clear;
          memo1.Text:=tempv;
          memo1.SelectAll;
          key := #0;
        end;end;