I'm using Visual Studio 2005 and have a Form with a MaskedTextBox.
In the Property Grid, i set AsciiOnly to true. All other properties
are unchanged. Despite that, when I run the program, the MaskedTextBox
still accepts numerals and commas, etc... To my knoledge when the AsciiOnly
is set to true, the MaskedTextBox is supposed to restrict input to only A-Z and a-z.
It appears that the AsciiOnly property is not working.
Am I missing something here?
Loading
Paul ChinPosted Sep 23, 2007, 10:47 PM
AlanPosted Sep 23, 2007, 11:44 AM
Again the documentation is about as clear as mud, but I think what you're seeing, Paul, is in fact the correct behaviour.
When the AsciiOnly property is set to false:
& represents any character at all and must be input.
C also represents any character at all but is optional.
When you set the AsciiOnly property to true, I think it simply restricts the range of the characters to numbers 32 to 127 but they can still be anything in that range including numerals and punctuation. So, when it talks about restricting it to a-z and A-Z, I think it must be saying that non-Latin letters are not allowed but that doesn't prevent you from inputting non-letter characters in the Ascii range as you could before.
Paul ChinPosted Sep 23, 2007, 10:55 AM
Even when I have set the mask as C or & and at the same time set the AsciiOnly to true, the MaskedTexBox still accepts any characters, eg, numerals, commas, period, etc...
It seems that the AsciiOnly property is non-functional. ;-)
AlanPosted Sep 23, 2007, 7:03 AM
The documentation on the AsciiOnly property is confused but I think that what it means is that it can only accept characters in the Ascii range apart from control characters - in other words, anything with a character value of between 32 and 127 which would include not just Roman letters but numerals and punctuation symbols as well. However, it would exclude letters in non-Roman alphabets.
Whether or not this property is set to true has an affect on certain Mask characters such as &, C and A by restricting them to a-z or A-Z. However, to always restrict input to these letters it's easiest to just use the L character.