Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Enabling keypress KeyChar

Posted on 2009-05-19
1
Medium Priority
?
291 Views
Last Modified: 2012-06-21
Hi,
I want to enable "-" inside the if statement what should i add to include it?
Is there a list of Chars i can refer to incase i want to add in other characters in the future.

Thanks for the help in advcance
if (!char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != '\b')
            {
                e.Handled = true;
            }

Open in new window

0
Comment
Question by:csharp_learner
1 Comment
 
LVL 3

Accepted Solution

by:
SafeCode earned 1400 total points
ID: 24420196
Hi,
to make if statement true for symbols but backspace or minus, add e.KeyChar != '-'

list of escape sequences can be found here:
http://blogs.msdn.com/csharpfaq/archive/2004/03/12/88415.aspx

Hope this helps!
if (!char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != '\b' && e.KeyChar != '-')
            {
                e.Handled = true;
            }

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question