How to 'align' text in RichTextBox C#?

You would have to change the font to a monospaced font, like Courier. This behavior you're showing is standard with most fonts, as not all characters are the same width.


You want to use the RichTextBox.SelectionAlignment property.

For instance if you want the whole textbox centered, then you would do:

richTextBox1.SelectAll();
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;

If you want only part of the textbox with a certain alignment, then use the RichTextBox.Select() routine to select the text, then set the SelectionAlignment property.


richTextBox1.SelectAll();
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
richTextBox1.DeselectAll();