Hi.
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.
add text to the last line?
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: add text to the last line?
If you want to add it when generating document, use AddNL method:
If you want to add it as an editing operation (undoable):
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)
Code: Select all
rv.AddNL('Signature', StyleNo, ParaNo);
rv.Format;
Code: Select all
// moving caret to the end
rv.BeginUndoGroup(rvutInsert);
rv.SetUndoGroupMode(True);
rv.SetSelectionBounds(
rv.ItemCount-1, rv.GetOffsAfterItem(rv.ItemCount-1),
rv.ItemCount-1, rv.GetOffsAfterItem(rv.ItemCount-1));
rv.CurTextStyleNo := StyleNo;
// inserting
rv.InsertText(#13#10'Signature');
rv.ApplyParaStyle(ParaNo);
rv.SetUndoGroupMode(False);
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)