You can programmatically change the font of a subset of text from a string control or indicator by following these steps:
- Right-Click on the string control or indicator and select Create»Property Node»Text»Selection»Start
- Right-click on the Text.SelStart property and select Create»Constant. This specifies the offset of the first character of the selected text.
- Expand the property node to expose a second property.
- Left-click on this second property and select Text»Selection»End.
- Right-click on the Text.SelEnd property and select Create»Constant. This specifies the offset of the last character of the selected text.
- Expand the property node to expose a third property.
- Left-click on the third property and select Text»Font >> then the font property to be programmatically controlled.
- For example: Select Text >> Font >> Color to bring up the Text.FontColor property on the Property Node. Right-click on the property's input node to Create Constant, then left-click on the created Color Box Constant and select a color from the palette.
- Repeat steps 6 and 7 to programmatically control additional font characteristics for the selected text.
Note: The
Text >> Font properties (like Text.FontColor and Text.FontBold) will change the formatting for
only the text selection (from SelStart to SelEnd indices). The
Text >> Text properties (e.g. Text.TextColor) will change formatting for
all text in the string.
The snippet below provide an example of different ways you can apply these properties.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
The outcome of the code above is the following formatted string control.
Additional Information