Page 1 of 1

How to delete Very Last line added in TRichView?

Posted: Sat Sep 30, 2006 6:36 pm
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

Posted: Sat Sep 30, 2006 7:24 pm
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

Posted: Sat Sep 30, 2006 8:20 pm
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

Posted: Tue Oct 03, 2006 10:57 am
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.

Posted: Tue Oct 03, 2006 6:52 pm
by jnap
Thank you, it works perfectly.

jnap