Disable white space on key press in textbox
c#, keypress, textbox, winforms
Solution
that's what you want, disallows all spaces
private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = (e.KeyChar == (char)Keys.Space);
}
Problem
I am beginner in WinForms so i would like to learn that, How can i disable white space keypress in textbox? ``` private void TextBox1_KeyPress(object sender, KeyPressEventArgs e) { // MyTextBox.Text ...? } ``` Any help will be appreciated.