add text to the last line?

General TRichView support forum. Please post your questions here
Post Reply
Posts: 1
Joined: Fri Sep 01, 2017 8:57 am

add text to the last line?

Post by Vincent » Fri Sep 01, 2017 9:06 am

I'm using RichViewEdit,
Is there a way to add text to the last line?
Like the signature of a mail.
Thank you for reference link.
Sorry my english.
Best Regared, Vincent.

Sergey Tkachenko
Site Admin
Posts: 13758
Joined: Sat Aug 27, 2005 10:28 am

Re: add text to the last line?

Post by Sergey Tkachenko » Fri Sep 01, 2017 11:31 am

If you want to add it when generating document, use AddNL method:

Code: Select all

rv.AddNL('Signature', StyleNo, ParaNo);
If you want to add it as an editing operation (undoable):

Code: Select all

// moving caret to the end
  rv.ItemCount-1, rv.GetOffsAfterItem(rv.ItemCount-1),
  rv.ItemCount-1, rv.GetOffsAfterItem(rv.ItemCount-1));
rv.CurTextStyleNo := StyleNo;
// inserting
Since this code contains several operations (inserting text and applying paragraph style), I added BeginUndoGroup+SetUndoGroupMode to group them in a single undo item.

This code uses two variables:
- StyleNo defines text properties, index in rv.Style.TextStyles
- ParaNo defines paragraph properties, index in rv.Style.ParaStyles.
Normally, indexes of plain text are zeros (so use StyleNo = ParaNo = 0)

Post Reply