Solved

Enabling keypress KeyChar

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

22 Experts available now in Live!

Get 1:1 Help Now