如題:即不能回車換行,只可以輸入一行。
謝謝!

解决方案 »

  1.   

    这样行不行:procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if (Key = #13) or (Key = #10) then Key := #0;
    end;
      

  2.   

    上面的代码也要用。再用上下面的代码:procedure TForm1.FormCreate(Sender: TObject);
    begin
      RichEdit1.ScrollBars := ssHorizontal;
      RichEdit1.WordWrap := False;
    end;
      

  3.   

    procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key = #13 then key:= #0;
    end;procedure TForm1.RichEdit1Change(Sender: TObject);
    begin
      if richedit1.Lines.Count>1 then
      begin
        keybd_event(VK_BACK, MapVirtualKey(VK_BACK, 0), 0, 0);
        keybd_event(VK_BACK, MapVirtualKey(VK_BACK, 0), KEYEVENTF_KEYUP, 0);
      end;
    end;
      

  4.   

    keypress要把form的key preview属性改成true
      

  5.   

    直接 设置  WantReturns 属性为 false 就行了 ,什么代码都不用写