Search code examples
c#winformssuperscript

SuperScript Label or Form name


How do i show superscripted string in Label or form name property.

enter image description here

I have found few questions like this one but was wondering if there is an way to do it for characters like 'a-z'?


Solution

  • You should better rely on the control meant for text-decoration: RichTextBox. You can configure it such that it looks like a Label. Sample code (richTextBox1 on main form):

    richTextBox1.BackColor = richTextBox1.Parent.BackColor; //Backcolor of the RTB's container
    richTextBox1.BorderStyle = BorderStyle.None;
    richTextBox1.Text = "Bloggerx";
    richTextBox1.Font = new Font(richTextBox1.Font.FontFamily, 10);
    richTextBox1.SelectionStart = 7;
    richTextBox1.SelectionLength = 1;
    richTextBox1.SelectionCharOffset = 5;
    richTextBox1.SelectionLength = 0;
    

    Another option you have is relying on two different labels, adequately coordinated to get the appearance you want.

    UPDATE

    There is still another option (although I personally wouldn't use it) which is playing around with the encoding and the font families (some of them support super-and sub-scripts). Another answer has proposed what, in my opinion, is a very bad way to account for this alternative (relying on an external program); there are better ways to implement that. But, in any case, I don't think that this is a systematic, reliable and easy to implement method (you have to find the corresponding format and make sure that it accounts for all the situations you want); but something mention-worthy though.