How to add a new line when #13

General TRichView support forum. Please post your questions here
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post 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
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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?
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post 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
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Change

Code: Select all

AKey:= '#13#10';
to

Code: Select all

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