473,382 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how to filter out non-digit chars when user writes text to System.Windows.Forms.TextBox

Hi,
how to filter out non-digit chars when user writes text to System.Windows.Forms.TextBox?

Thanks,
Iavmn
Nov 17 '05 #1
3 2465
> Hi,
how to filter out non-digit chars when user writes text to
System.Windows.Forms.TextBox?

Thanks,
Iavmn


Subscribe to the TextBox.KeyPress event. Check the character in the event
arguments. If it's a non-digit, set e.Handled=true; and that should prevent
the character from being allowed. You might want to do a beep or something
as well.

Pete
Nov 17 '05 #2
Pete Davis wrote:
Hi,
how to filter out non-digit chars when user writes text to
System.Windows.Forms.TextBox?

Thanks,
Iavmn

Subscribe to the TextBox.KeyPress event. Check the character in the event
arguments. If it's a non-digit, set e.Handled=true; and that should prevent
the character from being allowed. You might want to do a beep or something
as well.

Pete


that worked. thanks
Ivan
Nov 17 '05 #3
Note that this technique only prevents users from manually typing the
non-digit characters in the textbox - they can still paste the non-digit
characters from the clipboard. You might want to also implement an event
handler for the TextChanged property and replace all non-digit characters
there.

"Ivan" <iv*********@dynamic-imaging.com> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...
Pete Davis wrote:
Hi,
how to filter out non-digit chars when user writes text to
System.Windows.Forms.TextBox?

Thanks,
Iavmn

Subscribe to the TextBox.KeyPress event. Check the character in the event
arguments. If it's a non-digit, set e.Handled=true; and that should
prevent the character from being allowed. You might want to do a beep or
something as well.

Pete


that worked. thanks
Ivan

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Logan | last post by:
I read in PEP 279 the following comment by GvR: "filter and map should die and be subsumed into list comprehensions, not grow more variants." Actually, I am using 'filter' and 'map' a lot in...
181
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ...
4
by: Lasse Edsvik | last post by:
Hello I was wondering if you guys could help me. im building a small messageboard and i want to filter all html-tags except these ones: <b> <i> <img.........> <font....> how to build such...
4
by: Nicolae Fieraru | last post by:
Hi All, I have some javascript code and I try to filter out any characters (which are not digits or delete) from an input element in a form. Here is the code: <!DOCTYPE HTML PUBLIC...
1
by: Chris Simmons | last post by:
Hello: I am trying to better understand the HttpResponse.Filter property and, although I think I "get it," I am wondering what is going on behind the scenes. I was initially stumped with the...
3
by: Pablito | last post by:
Hi at all please can you inform me how I can use style="FILTER:alpha(opacity=0 to obtein dinamics image effects like fade ? Infact I tryed to use it from javascripts but I am unable from ...
2
by: Jeff Calico | last post by:
Hello everyone I have sucessfully implemented a SAX filter to take a large XML data file, and strip it down to its essential elements, and then pass that on to an XSL transformer. (A bare bones...
4
by: randy1200 | last post by:
Using Visual Studio 2005. I'm using XmlReader to read data into a string variable in C#. Works great! Every once in a while, I see that the string data contains a symbol that looks like a...
15
by: Briansmi1116 | last post by:
I created two buttons, that filter my form, They filter in different Fields, and if one is filtered, and the other is not there is a certain amount of record, if they are both pushed, then there is...
1
by: jas2803 | last post by:
Hello, I am using Vb6. I am receiving data over a commport, but for some reason erroneous data sometimes comes with it, I will get ascii characters and non printable characters quite often. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.