473,320 Members | 2,098 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,320 software developers and data experts.

Character Set for TextBox

Hi,
I would like to allow only some pre-defined characters to be typed in a
TextBox (for example only integer numerical, or float numerical, or only
a set of letters and so on). How can this be achieved with Visual Studio
..NET 2005 (I am using C#) ? I found a PreviewKeyDown event for the
TextBox, but I dont see how to "block" the typing of certain characters.
Or is there some other way to get such a functionality ?
Thanks in advance for your help.
Abra
*** Sent via Developersdex http://www.developersdex.com ***
Feb 1 '06 #1
2 2894
MaskedTextBox should help

http://msdn2.microsoft.com/en-us/lib...us,VS.80).aspx

--
Thanks
Vipul Patel
C# MVP www.microsoft.com/mvp
Log bugs at http://msdn.microsoft.com/productfeedback
"Abra" <no****@devdex.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi,
I would like to allow only some pre-defined characters to be typed in a
TextBox (for example only integer numerical, or float numerical, or only
a set of letters and so on). How can this be achieved with Visual Studio
NET 2005 (I am using C#) ? I found a PreviewKeyDown event for the
TextBox, but I dont see how to "block" the typing of certain characters.
Or is there some other way to get such a functionality ?
Thanks in advance for your help.
Abra
*** Sent via Developersdex http://www.developersdex.com ***

Feb 1 '06 #2
Thanks for the hint !
Some questions about the MaskedTextControl. If I choose UInt16 as
validation type, I still can input a number bigger than 65535 without
getting an InputRejected event.
If I choose Int32 (or Int16) as validation type, I cannot input negative
sign in front of number (InputReject event is fired if '-' is entered),
so that input of negative numbers is not possible.
Is there any solution for these problems ?
Is it possible over some property to force hexadecinmal input ?
Thanks in advance.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 3 '06 #3

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

Similar topics

9
by: refer_to_website | last post by:
My VB.NET web application has a textbox where the user is allowed to enter up to 50 characters. I have a label on the form next to the textbox that tells the user how many remaining characters he...
9
by: Jerry | last post by:
In limiting textbox input to 500 characters I would like to include a dynamic count of characters input while the user is typing into a textbox. This would obviously be a client side control,...
5
by: Susan Geller | last post by:
Character returns stored in a table do not display in a textbox or on a datagrid on my .net form. The text displays without the returns making the text difficult to read. When I "view source" on...
13
by: BluDog | last post by:
Hi I want to be able to work out the character under the mouse as it moves over a TextBox... I was thinking about aproaching it by measuring the string and working it out that way. I am not...
0
by: Phil C. | last post by:
(Cross post from framework.aspnet.security) Hi. I testing some asp.net code that generates a 256 bit Aes Symmetric Key and a 256 bit entropy value. I encrypt the Aes key(without storing it as...
2
by: Nathan Sokalski | last post by:
I have been trying to make a (supposedly) simple control. The control is nothing more than a control used to select integers, I was planning on making it a UserControl composed of a TextBox and 2...
5
by: Kay | last post by:
Hi All, I'm trying to write a small sub/function to replace some (invalid) character in a combo box, or may be even text box. For example, I have several combo boxes that allows user to select...
2
by: RN1 | last post by:
Assume that a TextBox is validated with the following RegEx (users can enter any number from 1 to 9 in the TextBox): <asp:TextBox ID="txt" runat="server"/> <asp:RegularExpressionValidator...
3
by: tparks69 | last post by:
I'm getting some Chinese language data from sql server in some encoded format, maybe unicode?... it starts with an ampersand '&', then there is a '#' pound sign, then a 5 digit integer, then a semi...
4
by: HenrikL | last post by:
Hi! I have textbox that have fixed size in GUI and I need to know how many character I can put into it. For example, the textbox can contain 5 character in GUI and I wan to check if this string...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
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.