It is necessary to simulate the display device using a textbox. How to make a textbox have 2 lines of 40 characters each, regardless of the width of characters?
1 answer
After enabling multiline properties for text boxes, the transfer every 40 characters can be implemented with this code
for (int i = 1; i < textBox1.Text.Length; i++) if (i%40==0) textBox1.Text = textBox1.Text.Insert(i, Environment.NewLine); Or simply:
textBox1.Text = textBox1.Text.Substring(0,80); if (textBox1.Text.Length > 40) textBox1.Text = textBox1.Text.Insert(40, Environment.NewLine); if you can drop all unnecessary.
|
Multiline = true, use a monospaced font and select the width and height of the test box. - Alexander Petrov