subscript text
-
Hi! Is it possible to format a string so that a certain part will be displayed as subscript text? For example a label displays the string "n1 + n2 =" and "1" and "2" should be subscript. I searched through the documentation but must have missed it, at least i hope so ;) THX in advance
-
Hi! Is it possible to format a string so that a certain part will be displayed as subscript text? For example a label displays the string "n1 + n2 =" and "1" and "2" should be subscript. I searched through the documentation but must have missed it, at least i hope so ;) THX in advance
There are several ways. One is through markup like with HTML that uses the
<sup>
and<sub>
tags. I doubt that's appropriate here, however. Another is to get a font that is full of these. It's not uncommon to have a font represent symbols. Microsoft uses several fonts for glyphs in Outlook and other applications. Since .NET supports Unicode, there is the superscript and subscript diacritics in the U+2070 through U+209F range. The problem is that you need a font that supports them. Tahoma (default font) and Arial Unicode MS currently do not, nor do any of the other common ones. If you had a font that supported this Unicode range and displayed the text in aTextBox
(for example), then you could use:"n\u2081 + n\u2082 ="
Finally, about your only other option is to owner-draw the text yourself in parts using
Graphics.DrawString
and either off-setting the coordinates of the upper-left corner or using aStringFormat
with aLineAlignment
set accordingly.Microsoft MVP, Visual C# My Articles