In textbox ChangedText event handler you can check on the character the user enters, Char.IsSymbol, Char.IsDigital, you'll make use of Char class.
- If you searched in this forum you'll find a lot of threads talk about that too..
*Show us your effort*
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
Check the KeyEventArgs in your TextBox KeyDown event handler.
Don't annoy a user with an error messagebox, simlpy do nothing when a user types in anything other then letters.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Ddanbe has given the correct answer. When the key is pressed if you dont want it, you can do something about it then.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
The order in which the Key event are fired is :
KeyDown
KeyPress
KeyUp
Any filtering of chars should be done in KeyDown or KeyPress events.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Not all keys appear in a keypress, but they do in the keydown/up
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
You could also check out this snippet :
http://www.daniweb.com/code/snippet1094.html
Here only "numeric" input is allowed, even the input of only one decimal point is taken into account.
It is the opposite of what you want, but it seems to me that it is easy to change that into something you want.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661