How to delete Very Last line added in TRichView?

General TRichView support forum. Please post your questions here
Post Reply
jnap
Posts: 31
Joined: Sat Sep 30, 2006 6:23 pm

How to delete Very Last line added in TRichView?

Post by jnap »

How is it possible to remove the Last line of text that has been added in a TRichView?

I need this last line to be removed as I am using it as an Invalid Password Log and when the Good Password is entered this should be removed from RichView before being displayed.

Many thanks

jnap
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

DeleteItems + Format (index of the last item is ItemCount-1)
Or, if you need to delete a paragraph, and the document is already formatted, you can use DeleteParas
jnap
Posts: 31
Joined: Sat Sep 30, 2006 6:23 pm

Post by jnap »

Hi, Thank you for your reply

Could you give an example please,

I have tried using Form2.RichView1.DeleteItems(1,-1); and then did the format but it didn't delete the last line added

Many thanks

jnap
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

To delete the last item, call

Code: Select all

rv.DeleteItems(rv.ItemCount-1, 1).
rv.Format;
DeleteItems may produce incorrect documents (See "Valid Documents" in the help file). If the last paragraph is bulleted/numbered and contains only one item after the list marker, the code above produces incorrect document.

To delete the last paragraph, call

Code: Select all

rv.DeleteParas(rv.ItemCount-1, rv.ItemCount-1);
Calling Format is not necessary, but it is required that the document is formatted before calling DeleteParas.
jnap
Posts: 31
Joined: Sat Sep 30, 2006 6:23 pm

Post by jnap »

Thank you, it works perfectly.

jnap
Post Reply