Deletion line/para

General TRichView support forum. Please post your questions here
Post Reply
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Deletion line/para

Post by vit »

Is it possible to delete line/para using SetSelectionBounds+DeleteSelection instead of DeleteItems+Format/DeleteParas?

I use DeleteItems and sometimes I get exception during the Format execution. I guess the cause is that document is incorrect.
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, DeleteItems may create invalid document (see http://www.trichview.com/help/valid_documents.html ).

However, if you use DeleteParas, it should be safe.

You can use SetSelectionBounds+DeleteSelection. Note that
- this operation is undoable; if you will use it in combination with non-undoable operations, the undo buffer will contain invalid data, and you need to clear it using ClearUndo;
- to delete the paragraphs from the M to N, y need to select either from the end of the paragraph M-1 to the end of the paragraph N, or from the beginning of the paragraph M to the beginning of the paragraph N+1.
If you select from the beginning of M to the end of N, DeleteSelection will produce an empty line in the place of deletion.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Thanks! I've tried to do like this

Code: Select all

RVData.SetSelectionBounds(FirstItemNo, RVData.GetOffsBeforeItem(FirstItemNo), LastItemNo + 1, RVData.GetOffsBeforeItem(LastItemNo + 1));
FRVE.DeleteSelection;
and it works properly!
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Assuming that LastItemNo is not the last item, i.e. LastItemNo+1 < RVData.ItemCount
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

yes of course
Post Reply