1

I know there is masked textbox component for C#, but what I need is to create masked text box which requires entered text in format: LLL/LLL but when I enter such mask into Mask property in preview and mask I see separator "." but not "/" as I want to have. Any help? Thanks

2 Answers 2

4

The / character is the date separator character in the mask. What you'll actually get depends on your culture preferences. To get a literal / you'll have to escape it with a \. Like this:

        this.maskedTextBox1.Mask = @"LLL\/LLL";

Don't use the @ when you use the Properties window.

Sign up to request clarification or add additional context in comments.

Comments

1

Thanks for this clue there is one more problem in maskedtextbox that is when the system short date changes the mask also changes for example..

Before

System date : d/M/yy  
Mask Format : __/__/__

After

System date : d-M-yy  
Mask Format : __-__-__ 

Using escape char hepled me.

Just add escape char in mask. For example:

textbox1.Mask = 00/\00/\00

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.