Cannot apply text style

General TRichView support forum. Please post your questions here
Post Reply
Jeff
Posts: 4
Joined: Wed May 19, 2010 3:28 pm

Cannot apply text style

Post by Jeff »

Hello - I am using the following code to add some text to a document:
rve.Clear;
rve.ApplyTextStyle(6); // a style
rve.ApplyParaStyle(1); // a paragraph style
rve.InsertText('Here is a line of text');

The text is inserted, but not in the font and font size I specified in the text style (6) above. I have also tried

rve.Clear;
rve.AddNL('Here is a line of text'',6,1);
rve.Format;

No doubt I am missing something simple? I searched help and forums with not much success.

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

Post by Sergey Tkachenko »

Both these code samples must work. You only need to add rve.Format after rve.Clear in the first example (because editing method require formatted document):
rve.Clear;
rve.Format;
rve.ApplyTextStyle(6); // a style
rve.ApplyParaStyle(1); // a paragraph style
rve.InsertText('Here is a line of text');

If it does not work, please create a simple example reproducing this problem and send it to me by email.
Jeff
Posts: 4
Joined: Wed May 19, 2010 3:28 pm

Post by Jeff »

I put together an example and the code worked correctly.
I fixed the problem in my project, but I am not sure as to the root cause.
The RVE field is populated from a database. If I would Null the database field out, the code would work correctly.
I also noticed that when I cleared a document and saved it to the database field, the field was in fact not empty, some information was there (binary format) and so it had something to do with this. Thanks
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand how empty/not empty data in the field can affect this problem.

And yes, even empty document contains some data (for example, collections of styles, background, etc.)
Post Reply