Page 2 of 2

Posted: Sun Oct 28, 2012 7:49 pm
by Sergey Tkachenko
If line breaks are displayed in memo, they will be displayed in TRichView too.
Demo: http://www.trichview.com/support/files/Memo2RV.zip
Image

Posted: Sun Oct 28, 2012 8:10 pm
by pawnflakes
But what i'm trying to make you understand is that the text in the memo is:

This #13#10 is #13#10 a #13#10 test

AND NOT

This
is
a
test

Posted: Sun Oct 28, 2012 8:44 pm
by Sergey Tkachenko
If you have such string in s, you can replace '#13#10' to line break characters #13#10 using this procedure (it is not very efficient, but it works):

Code: Select all

var p: Integer;

  p := Pos('#13#10', s);
  while p>0 do begin
    Delete(s, p, 6);
    Insert(#13#10, s, p);
    p := Pos('#13#10', s);
  end;
But this is a bad solution. A good solution is inserting line breaks characters in the first place.

Can you post the code where you add '#13#10' when the user presses Enter?

Posted: Sun Oct 28, 2012 9:00 pm
by pawnflakes
The component that I use has a OnKey event where keys pressed get trapped. If for instance the enter key is pressed, i can then add a #13#10 code to my string. I am currently using the following:

OnKey event
if AKeyNames.KeyChar = #13 then
AKey:= '#13#10';
The text then gets saved to the DB

Posted: Mon Oct 29, 2012 8:56 am
by Sergey Tkachenko
Change

Code: Select all

AKey:= '#13#10';
to

Code: Select all

AKey:= #13#10;
(remove quotes)