0 c# validation spaces winforms
不允许第一个字符作为空格后文本框允许窗口中的空格形式应用程序像
textbox1.text=" fg"; //----------- not like
textbox1.text="vcvc hfh"; //------------Like this
Run Code Online (Sandbox Code Playgroud)
您可以将此代码放在TextChanged事件或OnKeyDown事件中(或者您可以随时使用它)
string myString = textBox1.Text.TrimStart()
Run Code Online (Sandbox Code Playgroud)
甚至直截了当
textBox1.Text = textBox1.Text.TrimStart()
Run Code Online (Sandbox Code Playgroud)