How can I make a TextBox
only accept alphabetic characters with spaces?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
You could use the following snippet:
You can try by handling the
KeyPress
event for the textboxAdditionally say allow backspace in case you want to remove some text, this should work perfectly fine for you
EDIT
The above code won't work for paste in the field for which i believe you will have to use
TextChanged
event but then it would be a bit more complicated with you having to remove the incorrect char or highlight it and place the cursor for the user to make the correction Or maybe you could validate once the user has entered the complete text and tabs off the control.Please Try this
This one is working absolutely fine...
you can try following code that alert at the time of key press event
Here is my solution and it works as planned: