471,603 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 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 2843
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by refer_to_website | last post: by
9 posts views Thread by Jerry | last post: by
5 posts views Thread by Susan Geller | last post: by
13 posts views Thread by BluDog | last post: by
reply views Thread by Phil C. | last post: by
2 posts views Thread by Nathan Sokalski | last post: by
2 posts views Thread by RN1 | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

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.