Page 1 of 1
Keep the current paragraph style after an InsertItem
Posted: Fri Oct 21, 2005 5:22 pm
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.
Posted: Sat Oct 22, 2005 8:06 am
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.
Posted: Sat Oct 22, 2005 10:32 am
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.
Posted: Sat Oct 22, 2005 10:56 am
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?
Posted: Sat Oct 22, 2005 11:41 am
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).
Posted: Sat Oct 22, 2005 7:38 pm
by Sergey Tkachenko
Add rvprDoNotAutoSwitch in the Protection property of the text style which is used for LabelItem.
Posted: Sat Oct 22, 2005 8:22 pm
by frank van den bergh
That works. Great. Thanks