Enables HTML formatting.
Usage
Set_Property(OLECtrlEntID, "OLE.HtmlEnabled", Boolean)
Values
[True | False]
Default: False
Remarks
The HtmlEnabled property enables or disables HTML rendering of item text. By default, all item text is displayed as is. However, if you need access to more complex formatting, you can enable HTML rendering by setting this property to 1.
The HTML rendering capabilities of the SRP Tree Control is limited to a subset of HTML tags. The following tags are supported:
Tag | Description |
---|---|
<big>...</big> | Increases font size 2 points |
<b>...</b> | Bold Text |
<font>...</font> | Alters font face, size, and color |
<i>...</i> | Italic Text |
<small>...</small> | Decreases font size 2 points |
<s>...</s> | Strikeout Text |
<sub>...</sub> | Subscript Text |
<sup>...</sup> | Superscript Text |
<u>...</u> | Underlined Text |
<font>
The <font> tag supports three attributes: color, size, and face. The color tag can be set to any SRP OLE Control Color value, such as "3DFace", "Red", or "RGB(255, 0, 255)".
<font style="font-family: 'Consolas'; font-size: 10pt; color: 000000;"></font><font style=" font-family: 'Consolas'; color: #800000; ">'My <font color="ForestGreen">green</font> text.'</font>
The size attribute increases or decreases the font size. Use '+' or '-' to indicate the size change. There is currently no support for setting an exact point size. Only relative sizes are supported
<font style="font-family: 'Consolas'; font-size: 10pt; color: 000000;"></font><font style=" font-family: 'Consolas'; color: #800000; ">'My <font size="+4">big</font> and <font size="-4">tiny</font> text.'</font>
The face attribute changes the font face. Only one font can be specified, unlike true HTML, which allows you to specify a list of fonts.
<font style="font-family: 'Consolas'; font-size: 10pt; color: 000000;"></font><font style=" font-family: 'Consolas'; color: #800000; ">'My <font face="Comic Sans MS">fun</font> text.'</font>
When using HTML rendering, keep in mind the following limitations:
- There must be no whitespace after '<' or before '>' in a tag. So, <b> is correct but < b> or <b > is not correct. Likewise, <font size="+2"> is correct but < font size="+2" > is not.
- Attribute values must be encased in double quotes. So, <font color="red"> is correct but <font color='red'> is not.
- Changing font sizes on the same line does not produce the desired result. Ideally, the various sized fonts' baselines should be aligned, but this is currently not the case.
- Superscripts and subscripts are performed using a very rough calculation, so they will not appear as positionally accurate as they would in an internet browser.
Character Entities
Character entities are special strings that are replaced by commonly used symbols. The following character entities are supported:
Entity | Display Symbol | Description |
---|---|---|
& | & | ampersand |
• | • | bullet (not in available MS SANS SERIF) |
¢ | ¢ | cent sign |
© | © | copyright |
° | ° | degree sign |
€ | € | euro sign |
½ | ½ | fraction one half |
¼ | ¼ | fraction one quarter |
> | > | greater than |
¿ | ¿ | inverted question mark |
< | < | less than |
µ | µ | micro sign |
·, | · | middle dot = Georgian comma |
| nonbreaking space | |
¶ | ¶ | pilcrow sign = paragraph sign |
± | ± | plus-minus sign |
£ | £ | pound sign |
" | " | quotation mark = double quote |
® | ® | registered trademark |
§ | § | section sign |
¹ | ¹ | superscript one |
² | &up2; | superscript two |
× | × | multiplication sign |
™ | ™ | trademark (not available in MS SANS SERIF) |
Keep in mind that you can still use any unicode character in your item text, so it's easy to display symbols not included in this list. However, as is always the case with Unicode, you must always remember that some symbols are not supported by certain fonts. Be sure to test a symbol before using it in production.
Example
// Enable HTML rendering and set an item's text Set_Property(@Window:".OLE_TREE", "OLE.HtmlEnabled", 1) Set_Property(@Window:".OLE_TREE", "OLE.ItemData[Item1]", 'Hello <font color="blue">Blue</font> <i>World!</i>')