How to underline specific text in a shape?

57 Views Asked by At

I simply need to underline + bold PRI_SITETXT and SEC_SITETXT and leave all other text bold.

Shape SITEINFO_BOX = SITEINFO.DrawRectangle(1, 14.5, 11, 2.5);
SITEINFO_BOX.CellsU["LinePattern"].FormulaU = "0";
var PRI_SITETXT = "Primary SITE POC:";
var SEC_SITETXT = "Secondary SITE POC:";
            
    //SITEINFO_BOX.Characters.CharProps[(short)VisUIIconIDs.visIconIXUNDERLINE] = 52;

var PRI_POC = PRI_SITETXT + "\n" + TENANT_DATA_PARAM[0].pri_poc_name + "\n" +       TENANT_DATA_PARAM[0].pri_poc_email + "\n" + TENANT_DATA_PARAM[0].pri_poc_number;
var SEC_POC = SEC_SITETXT + "\n" + TENANT_DATA_PARAM[0].sec_poc_name + "\n" + TENANT_DATA_PARAM[0].sec_poc_email + "\n" + TENANT_DATA_PARAM[0].sec_poc_number;

SITEINFO_BOX.Text = PRI_POC + "\n" + "\n" + SEC_POC;

SITEINFO_BOX.CellsU["VerticalAlign"].FormulaU = "0"; // 0 = SEND TEXT TO TOP OF SHAPE
SITEINFO_BOX.CellsU["Para.HorzAlign"].FormulaU = "0";  // 0 

var POC_CHARS = SITEINFO_BOX.Characters;



var TARGET_ROW = POC_CHARS.CharPropsRow[(short)VisCharsBias.visBiasLetVisioChoose];

POC_CHARS.Begin = 0;
POC_CHARS.End = 17;
            POC_CHARS.set_CharProps((short)VisCellIndices.visCharacterColor, (short)VisDefaultColors.visBlack);
            TARGET_ROW = POC_CHARS.CharPropsRow[(short)VisCharsBias.visBiasLetVisioChoose];
            SITEINFO_BOX.CellsSRC[(short)VisSectionIndices.visSectionCharacter,
                         TARGET_ROW,
                         (short)VisCellIndices.visCharacterStyle].FormulaU = "21";

POC_CHARS.Begin = 59;
POC_CHARS.End = 78;
            POC_CHARS.set_CharProps((short)VisCellIndices.visCharacterColor, (short)VisDefaultColors.visBlack);
            TARGET_ROW = POC_CHARS.CharPropsRow[(short)VisCharsBias.visBiasLetVisioChoose];
            SITEINFO_BOX.CellsSRC[(short)VisSectionIndices.visSectionCharacter,
                         TARGET_ROW,
                         (short)VisCellIndices.visCharacterStyle].FormulaU = "21";

In a nutshell, while i want all of the text to be BOLD, PRI_SITETXT and SEC_SITETXT should also be underlined. the "Char.Style", "Char.Style[2]", etc.. are something that i was messing with because if i manually BOLD all text and manually underline Primary SITE POC and Secondary SITE POC vars and then head to developer tab -> show shapesheet -> shape the char.style and char.style[2], etc.. are all present with the corresponding values 21,17 etc.. so i assumed that if i simply added that to the code it would be valid, but this is not the case. (at least not that i could figure out)

I can easily bold all text and easily bold + underline all text (SITEINFO_BOX.CellsU["Char.Style"].FormulaU = "the appropriate value";) does both to all text within the shape.

Solved: MSVisio Characters custom color

specifically the following syntax:

(short)VisCellIndices.visCharacterStyle].FormulaU = "21" (value 21 = BOLD + UNDERLINE)

edited code above to reflect

1

There are 1 best solutions below

0
Calibus On

The path to the answer is found: MSVisio Characters custom color.

specifically replacing

(short)Visio.VisCellIndices.visCharacterColor].FormulaU = "RGB(40,220,40)";

with

(short)VisCellIndices.visCharacterStyle].FormulaU = "21";

although i am unfamiliar with the actual math behind determining the style values. a value of 21 = BOLD + Underline. and a value of 55 is BOLD + Underline + Italic.

you can find the values by selecting the shape then Developer tab -> Show ShapeSheet scroll down ~ 35% of the way until "Characters" (on the left hand side) and ~ the center of the page to "Style" Beneath you will discover the current values applied.