Question about the Mask property on the MaskedTextBox

G

Guest

I'm using the MaskedTextBox to make sure the user inserts a valid
international phone number. I want to set the Mask property so that the user
sees +49-__-____-____ in the text box.

I set the Mask property to "+49-00-0000-0000", but because 9 is a Masking
element the masked text box contains +4_-__-____-____

How can I pass a 9 (or 0) into the Mask property so that it is not treated
as Masking elements?

Thank you for your help.
 
N

Nicholas Paldino [.NET/C# MVP]

Mark,

The documentation for the Mask property indicates that you can use "\"
as an escape property to escape a mask character, turning it into a literal.
Given that, your mask would be "+4\\9-00-0000-0000" (I used the double
backslash in case you were not using the literal identifer in C#, you could
also use @"+4\9-00-0000-0000" as well).
 
G

Guest

Thank you Nicholas. That was the part of the puzzle I was missing.

Nicholas Paldino said:
Mark,

The documentation for the Mask property indicates that you can use "\"
as an escape property to escape a mask character, turning it into a literal.
Given that, your mask would be "+4\\9-00-0000-0000" (I used the double
backslash in case you were not using the literal identifer in C#, you could
also use @"+4\9-00-0000-0000" as well).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Mark Collard said:
I'm using the MaskedTextBox to make sure the user inserts a valid
international phone number. I want to set the Mask property so that the
user
sees +49-__-____-____ in the text box.

I set the Mask property to "+49-00-0000-0000", but because 9 is a Masking
element the masked text box contains +4_-__-____-____

How can I pass a 9 (or 0) into the Mask property so that it is not treated
as Masking elements?

Thank you for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top