Why does the first line of a textbox contain 1 more character than the others with monospaced font?

97 Views Asked by At

I have a textbox in windows forms with mono spaced font (Courier New, 10pt) so I assume that each line of the textbox will contain the same number of characters. However, sometimes the first line contains one more character than all the others.

This is how the textbox is formattet for the string textbox.Text = "?06?00?00?00?01?00?00?00?00?00?01?00?00?04?00?00?00?00?00?00?01?00?00?00?00?00?00?00?02?00?00?00?":

?06?00?00?00?01?00?00?00?
00?00?01?00?00?04?00?00?
00?00?00?00?01?00?00?00?
00?00?00?00?02?00?00?00?

The same text box looks like this for another string textbox.Text = "06 00 00 00 01 00 00 00 00 00 01 00 00 04 00 00 00 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 f4 01 00 00 ":

06 00 00 00 01 00 00 00 00 
00 01 00 00 04 00 00 00 00 
00 00 01 00 00 00 00 00 00 
00 02 00 00 00 f4 01 00 00 

Note that for the first string the textbox contains 25 characters in the first line and 24 in the others. For the second string the textbox contains 26 characters in each line (theres a space at the end of each line)

Is "Courier New" really a monospaced font? (I read in several places that it is.)

If "Courier New" is a monospaced font then why is this happening?

How can this be fixed? (I just want to have the same amount of characters in each line).

0

There are 0 best solutions below