RE: Determine if an input key is a number, letter or special character
- From: Morten Wennevik [C# MVP] <MortenWennevik@xxxxxxxxxxx>
- Date: Tue, 11 Aug 2009 22:13:01 -0700
Hi moondaddy,
You aren't telling is what kind of input you are talking about, but the Char
class has a set of static methods for determining what type a given character
is. For instance System.Char.IsDigit(), ...IsLetter(), ...IsControl().
If you mean input keys as in KeyEvent... there is no way to determine if a
given Key is a digit, letter or special character. You have to set up a list
of keys for each type, like D0-D9 + NumPad0-NumPad9 would mean digit input.
To ignore invalid entries in a TextBox, handle the OnKeyPress event and
check the Char value. If not valid, set KeyPressEventArgs.Cancel to true.
--
Happy Coding!
Morten Wennevik [C# MVP]
"moondaddy" wrote:
Is there a simple way to determine if an input key is a number, letter or.
special character? in other words, was the user inputting data and not
typing a backspace, shift, etc.
Thanks.
--
moondaddy@xxxxxxxxxxxxxxxx
- References:
- Prev by Date: Re: Help for a VB.Net guy
- Next by Date: Re: Did anyone ever go to India for training and certification?
- Previous by thread: Re: Determine if an input key is a number, letter or special character
- Next by thread: Re: Did anyone ever go to India for training and certification?
- Index(es):
Relevant Pages
|