programmatically adding subscripted string

General TRichView support forum. Please post your questions here
Post Reply
krctech
Posts: 7
Joined: Tue Jun 03, 2008 4:57 am
Location: San Diego, CA US

programmatically adding subscripted string

Post by krctech »

I want to be able to programmatically add text like H2O where the 2 is subscript. I'm trying to do this with

t.Cells[r, c].AddNLWTag('H'+#$2082+'O', NORMAL, RIGHT, '');

Except I simply see a box where the subscript "2" should be. What am I doing wrong?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: programmatically adding subscripted string

Post by Sergey Tkachenko »

The second parameter of AddNLWTag is the index of RVStyle.TextStyles collection.
Pass the index of item having SubSuperScriptType = rvsssSubScript

See also:
http://www.trichview.com/forums/viewtop ... 37&p=32795
This topic contains examples how to create text styles with required properties, including sub/superscript.
krctech
Posts: 7
Joined: Tue Jun 03, 2008 4:57 am
Location: San Diego, CA US

Re: programmatically adding subscripted string

Post by krctech »

Thanks Sergey, that helps. However, I need to be able to add three bits of text into a table cell. The actual string is something like this

'Pressure, in-H2O (a)'

Therefore, I need to add three successive strings:

leftStr := 'Pressure, in-H';
subScriptStr := '2';
rightStr := 'O (a)';

I am able to get add strings in the table cell, but each adds to its own line. I need them on the same line.

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

Re: programmatically adding subscripted string

Post by Sergey Tkachenko »

The second and the third string in the line must be added with -1 in ParaNo parameter of AddNLWtag.

PS: before adding content to a cell, clear it: Cell.Clear.
krctech
Posts: 7
Joined: Tue Jun 03, 2008 4:57 am
Location: San Diego, CA US

Re: programmatically adding subscripted string

Post by krctech »

perfect - thanks Sergey!
Post Reply