473,544 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2903
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******** *******@TK2MSFT NGP09.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 MaskedTextContr ol. 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
2525
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 can enter. This label needs to be refreshed on the fly each time the user types a character into the text box. Eventually, the user will click...
9
10091
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, possibly a custom validator with a function written in javascript. Has anyone done this? Does someone have an example? Regards
5
1580
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 the page, I see the returns and when I view the data in Enterprise Manager I can also see the returns. I have the same problem when I am looking at...
13
1906
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 convinced this is a) going to be very reliable, or b) very tidy. Anyone know of a good starting point for this kind of thing? THanks
0
3123
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 Base64) with the host's dpapi using the entropy value(without storing it as Base64), and then store the encrypted Aes key value and the entropy value...
2
1368
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 Buttons (basically like those controls you sometimes see in Windows applications). The functionality is obviously very simple code, and I was going...
5
1927
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 a time value, i.e. 21:30, however I also want to allow them to enter a time, as a result I want to replace comma, fullstop etc with a colon ":". ...
2
1156
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 ID="regexp" ControlToValidate="txt" ValidationExpression="" runat="server"/> As expected, any number deom 1 to 9 entered in the TextBox evaluates to...
3
5019
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 colon. I notice it gets translated when I post it exactly, so I'm trying to descibe it here. If I put some spaces between it, a single character...
4
3793
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 "234567.333" is not to large for the textbox, if it is then I wan to highlight the textbox.text = "#####" (like exel). Is there any easy way to...
0
7362
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7602
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7704
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5291
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3404
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1837
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
983
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.