I have a Windows Form with a Rich Textbox control on the form. What I want to do is make it so that each line only accepts 32 characters of text. After 32 characters, I want
I've been looking into this problem myself and have found a really easy way to get around this. You need to place a small piece of code in the Key_Down Event on your TextBox or RichTextBox control.
Ensure that both Word Wrap and Multiline properties are still set to true, then, you just need to check for the Key Press of KeyCode.Return & Keycode.Enter.
Like Below :-
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
{
e.Handled = true;
}
}
Setting the handled value you here to true, sends back the message that we have dealt with the Key Press event, and nothing happens. The Text Control continues to use Word Wrap and blocks the carriage return.
Hope this helps.