Keep the current paragraph style after an InsertItem

General TRichView support forum. Please post your questions here
Post Reply
frank van den bergh
Posts: 6
Joined: Thu Oct 20, 2005 2:29 pm
Location: The Netherlands

Keep the current paragraph style after an InsertItem

Post by frank van den bergh »

When you insert a TLabelItem at the end of a document with a style x, from then on you are using the style of the TLabelItem.

How can I keep the style of the paragraph? I want that when you enter some text after the insert action, you have the same paragraph style as before.

Thanks for your reaction,

Frank van den Bergh.
Sergey Tkachenko
Site Admin
Posts: 17287
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Text style or paragraph style?
Do you use AddItem to add LabelItem to the end of the document?
Set li.ParaNo = <required paragraph style> before the insertion.
frank van den bergh
Posts: 6
Joined: Thu Oct 20, 2005 2:29 pm
Location: The Netherlands

Post by frank van den bergh »

Hi Sergey,

I use InsertItem as AddItem does not work (no TLabelItem insertion in the document when the caret is at the end). I use the suggestion you gave me yesterday. This is the code:
li := TRVLabelItemInfo.CreateEx(RichViewEdit1.RVData, TEXTSTYLE_VARIABLE, '['+Variable.Description+']');
// RichViewEdit1.AddItem('', li);
If RichViewEdit1.InsertItem('', li)
then begin
rve := RichViewEdit1.TopLevelEditor;
ItemNo := rve.CurItemNo;
rve.SetSelectionBounds(ItemNo, rve.GetOffsBeforeItem(ItemNo), ItemNo, rve.GetOffsAfterItem(ItemNo));
rve.Invalidate;
end;

I'm only interested in text style (basically just another text color and style). I don't change the paragraph. I'm creating a kind of formula wizard. Sorry about the misunderstanding the paragraph.
Sergey Tkachenko
Site Admin
Posts: 17287
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

(AddItem is used for document generation, not for inserting at the caret position; It requires call of Format before displaying)

As far as I understand, your question is about a current text style after the insertion of label item. Which text style do you want to make current:
- a text style used in the inserted label item?
- or may be a style of text before the label item?
frank van den bergh
Posts: 6
Joined: Thu Oct 20, 2005 2:29 pm
Location: The Netherlands

Post by frank van den bergh »

You understand that correct. After the insert the text style of the inserted item is the current one. I want to continue with the one I had (your second option).
Sergey Tkachenko
Site Admin
Posts: 17287
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Add rvprDoNotAutoSwitch in the Protection property of the text style which is used for LabelItem.
frank van den bergh
Posts: 6
Joined: Thu Oct 20, 2005 2:29 pm
Location: The Netherlands

Post by frank van den bergh »

That works. Great. Thanks
Post Reply