My scenario is:
Not allowing spaces at starting position of textbox after enter one or more characters text box allows spaces
Below not applicable to my scenario.
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.Handled = (e.KeyChar == (char)Keys.Space)) { MessageBox.Show("Spaces are not allowed"); } }
textBox1.Text.TrimStart()