Reputation: 33
I am new to WinForms.
When I am trying to implement the masked text box, I got one error.
I want a mask of 00-00-1900
where 00
handle any number, but 19
is fixed and cannot be overwritten by the user. How do I do that?
Examples of valid input are 19-12-1988
and 12-01-1958
.
Upvotes: 1
Views: 1788
Reputation: 108810
0
Digit, required. This element will accept any single digit between 0 and 9.
9
Digit or space, optional.
\
Escape. Escapes a mask character, turning it into a literal. "\" is the escape sequence for a backslash.
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx
Since 9
is a special character, but you want to treat it as a literal, you need to escape it with \
.
So I guess your mask needs to be 00-00-1\900
which I'd write as @"00-00-1\900"
in C# code.
Upvotes: 2
Reputation:
00-00-1900 in Mask Take --1___ Because 0 and 9 are the Masked text which refers, numeric.
0 - Digit, required. This element will accept any single digit between 0 and 9.
9 - Digit or space, optional.
You Just Right Click The Masked Text Box, And Go to Property. Click and Change Mask to 00-00-1\900.
You will get what you want.
1900 to 1999 in 1900.
Upvotes: 1
Reputation: 127
Take a look at this, see the remarks section. Sadly, it doesn't state whether you can make the 19 aspect of the last four digits fixed - you may need to write your own checks to enforce this.
Upvotes: 0