473,327 Members | 1,930 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,327 software developers and data experts.

A couple of questions regarding TextBox

dln
Howdy. I'm a bit new to C# and got a couple of quick questions that perhaps
someone can help me answer. First, is there a property that you set on a
TextBox control that will force the control to accept only numerical data
(i.e. - only numbers 0 to 9, a decimal and the negative sign)? So far, I've
had to do the validation manually on either a key down or OnValidate event.
Secondly, is there any way to preview a key stroke for a given control and
then either accept or toss the value of the key stroke depending on some
sort of pre-defined rule? So for example, if a user were to enter hit the
"a" key while in a text box, what I would like to have happen is to have the
application eat the keystroke and not have the "a" character ever show up in
the text control. Is this possible? Any assistance provided would be
greatly appreciated.

Thanks.
Nov 15 '05 #1
1 1465
dln
Great! Thanks for the reply.

"Vijaye Raji" <no************@hotmail.com> wrote in message
news:O4**************@tk2msftngp13.phx.gbl...
Handling the KeyDown event is the way to go.

When you find some key is invalid, set the Handled property on the
KeyPressEventArgs to true - the character will not appear on the text
control.

HTH
-vJ

"dln" <dn**********@hotmail.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
Howdy. I'm a bit new to C# and got a couple of quick questions that perhaps
someone can help me answer. First, is there a property that you set on a TextBox control that will force the control to accept only numerical data (i.e. - only numbers 0 to 9, a decimal and the negative sign)? So far,

I've
had to do the validation manually on either a key down or OnValidate

event.
Secondly, is there any way to preview a key stroke for a given control and then either accept or toss the value of the key stroke depending on some
sort of pre-defined rule? So for example, if a user were to enter hit the "a" key while in a text box, what I would like to have happen is to have

the
application eat the keystroke and not have the "a" character ever show

up in
the text control. Is this possible? Any assistance provided would be
greatly appreciated.

Thanks.


Nov 15 '05 #2

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

Similar topics

8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
1
by: pcPirate | last post by:
Hi, In C# i) Is there anyway to input value on particular cell in datagrid in the coding? ii) How do I save the contents of the datagrid back to database? iii) I've made a custom...
1
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have created some classes based on the std classes but with a couple of new features. Now some questions. 1. I want to add a neet bitmap to each class that i have made, now when i...
4
by: Sccr18 | last post by:
I just have a couple of easy questions: 1. In Asp.net using Vb is there a way to list all the possible characters without listing them all like Char() = "abc..."? 2. I was trying to set the focus...
5
by: EdB | last post by:
1) How do I make the contents of a Windows datagrid editable while at the same time preventing new rows from being added? 2) How do I align the contents of a column align-right, but the header of...
2
by: Seguros Catatumbo | last post by:
Hi, i have decent experience with asp 3.0 (classic), and downloaded web developer express to see what's the fuzz over it. I have lots of questions, mostly regarding the use of forms and database...
7
by: Don | last post by:
I'm not very proficient with Access, probably only enough to make me dangerous. With that said I've got two questions. #1 (probably pretty simple). I know I've done this before but how do I get...
16
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, I am using Visual C# window to dispaly a set of questions with their answers. The users should be able to move to the next question by clicking on next button. I am going to use only one panel...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.