I have a MaskedTextBox that accepts alpha numeric chars but I also want to accept brackets "()". How can I change the mask to accepts brackets also?
Asked
Active
Viewed 2,833 times
1
-
Whats is your format of the numbers? – Mitja Bonca Aug 23 '11 at 12:46
2 Answers
1
See this answer to a similar question:
How to set Regex Expression as the Mask for a MaskedTextBox in C#?
Instead of using a mask, you should probably just use regular validation, and then you can use the regular expressions directly. Make sure that the CausesValidation property of the (regular, not masked) textbox is true, then intercept the Validating event and if the regular expression doesn't match, set the CancelEventArgs.Cancel to true.

Community
- 1
- 1

Luke Girvin
- 13,221
- 9
- 64
- 84
0
You can simply put this line of code into form constructor:
maskedTextBox1.Mask = "(000)000.000";

Mitja Bonca
- 4,268
- 5
- 24
- 30