Page 1 of 1

programmatically adding subscripted string

Posted: Tue Jun 13, 2017 6:34 am
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?

Re: programmatically adding subscripted string

Posted: Tue Jun 13, 2017 6:24 pm
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.

Re: programmatically adding subscripted string

Posted: Tue Jun 13, 2017 10:28 pm
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

Re: programmatically adding subscripted string

Posted: Wed Jun 14, 2017 8:30 am
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.

Re: programmatically adding subscripted string

Posted: Wed Jun 14, 2017 3:20 pm
by krctech
perfect - thanks Sergey!