Search code examples
c#.netwinformstextbox

C# .NET multiline TextBox with same-width characters


How can I make it so if you typed in a multiline TextBox:

abcde

ABCDE

So that the big E is directly below the little e. I want them to line up vertically if they are in the same row.


Solution

  • Can you just set the font on the textbox to a monospaced one?

    In code, keeping the same size as the default font:

    textBox.Font = new Font(FontFamily.GenericMonospace, textBox.Font.Size);
    

    Or just change the Font property in the designer.