0

Is there a way to underline a superscript in , but not as it is done by default, but as it is described here? It should be done in .

My simple code: Let's say, we have simple RTB called fixedRichTextBoxcs1 and we have a button1:

 private void button1_Click(object sender, EventArgs e)
    {
        this.fixedRichTextBoxcs1.Text = "This is result";
        this.fixedRichTextBoxcs1.Select(0, this.fixedRichTextBoxcs1.Text.Length);
        this.fixedRichTextBoxcs1.SelectionFont = new Font(this.fixedRichTextBoxcs1.SelectionFont, FontStyle.Underline);
        this.fixedRichTextBoxcs1.Select(0, 1);
        this.fixedRichTextBoxcs1.SelectionCharOffset = 15;
    }

And it doesn't work as intended, the result is: enter image description here

Paweł Poręba
  • 1,084
  • 1
  • 14
  • 37
  • The answer to your question is `Yes`. You basically answered it yourself. – kevintjuh93 Sep 14 '15 at 13:07
  • Can you expand your comment? The topic I've given a link to concerns WPF and unfortunately I am not familiar with it yet. – Paweł Poręba Sep 14 '15 at 13:12
  • @PawełPoręba as Kevin said, it is possible and I posted an example for you in windows forms – Reza Aghaei Sep 14 '15 at 13:30
  • @RezaAghaei I commented under your answer, it doesn't solve my problem, it's default behaviour. – Paweł Poręba Sep 14 '15 at 13:32
  • It works just fine. "Pretty" is not a word that applies, this isn't supported directly by the text rendering engine. RTB tries its best to do what you ask. If you want 1 to be underlined more visibly then you'll have to ask for that, set the SelectionStart and SelectionLength properties so only the "1" is selected. – Hans Passant Sep 16 '15 at 22:59
  • @HansPassant Can you provide some example? I've really tried that, selecting only "1" and it doesn't work. Why is it that the code proposed by RezaAghaei works for him, but not for me? We have the same OS version, .NET version and VS too.. – Paweł Poręba Sep 17 '15 at 08:20
  • Your screenshots are useless, post code. – Hans Passant Sep 17 '15 at 08:24
  • @HansPassant I've added some code to my question. – Paweł Poręba Sep 17 '15 at 08:46
  • 1
    Hmm, your snippet has nothing to do with your screenshot. And is buggy, using both this.fixedRichTextBoxcs1 and this.richTextBox. This just can't seem to get better, maybe you ought to try it again a year from now. – Hans Passant Sep 17 '15 at 08:55
  • @HansPassant I've corrected it, sorry. Can u check this now? FixedRichTextBox is the one that remove AutoWordSelection bug and also implement "RichEdit50W" instead of "RichEdit20W". But this code also doesn't work for default RTB. Is it still something I do wrong? – Paweł Poręba Sep 17 '15 at 09:03
  • No, the answer doesn't solve my problem, it just doesn't work. – Paweł Poręba Oct 09 '15 at 21:29

0 Answers0