I set the property Multiline=true;
.
I do not want to allow the Enter Key to make a new line.
How can I solve this issue?
That could be as simple as listening to TextChanged
event and then executing the following line inside it:
txtYourTextBox.Text = txtYourTextBox.Text.Replace(Environment.NewLine, "");
This solution involves some screen flicker though. A better way is to prevent it entirely by listening to KeyDown
event:
private void txtYourTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
e.SuppressKeyPress=true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With