Solved

Enabling keypress KeyChar

Posted on 2009-05-19
1
284 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 350 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now