none
underlining a superscript, WinForms RRS feed

  • Question

  • Is there a way to underline a superscript in Windows Forms, but not as it is done by default, but as the baseline still stayed the same? I'm using RichTextBox and SelectionCharOffset property to do a superscript I mean that i don't want the underlining go up with superscript.
    Wednesday, September 16, 2015 7:25 AM

All replies

  • Hi smmileey,

    Thank you for your post. Your question is more related to Windows Forms. We will move your thread to Windows Forms General forum. You will get more help there.

    Best Regards,
    Li Wang

    Thursday, September 17, 2015 2:01 AM
  • Hi smmileey,

    If the superscript is interger or some small letters you could use Unicode superscript.

    richTextBox1.BorderStyle = BorderStyle.None;
                richTextBox1.Text = "unit\u00B2sdfa";  //this is superscript 2.
                richTextBox1.Font = new Font(richTextBox1.Font.FontFamily, 30, FontStyle.Underline);

    You could find the corresponding code for each number from the link.

    https://en.wikipedia.org/wiki/Superscripts_and_Subscripts

    Regards,
    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 17, 2015 6:14 AM
    Moderator
  • @YoujunTang Thanks for your reply. Unfortunately, this solution doesn't solve the entire problem, because it there are still other signs and it's time consuming.

    I've tried to replace "RichEdit20W" to "RichEdit50W", but it still doesn't work. And yet in WordPad the same behaviour is successful. Weird...
    Saturday, September 19, 2015 10:06 AM
  • Hi,

    You'd like to have a distance between superscript and its underline? In winforms, I think it is default behavior when you use SelectionCharOffset property.

    If possible, you could submit this feature request: http://visualstudio.uservoice.com/forums/121579-visual-studio.

    Monday, September 21, 2015 9:04 AM
  • Thanks for your reply _Omar.

    This is exactly what I would like to achieve and it is strange for me that it doesn't work for me. What's more strange the same code seems to work at my colleague's computer with same specifications..
    Thursday, September 24, 2015 7:38 AM