Deny spaces in MaskedTextbox

How can I prevent spaces in maskedtextbox? Used by KeyPress, but e.handled does not work. Can someone direct me to a post that shows how to handle this? A masked text field is used for ssn. Thanks

+3
source share
2 answers

Instead of 9 you need 0, due to 9 valid spaces as valid characters

The US Social Security number mask will look like this:

myMaskedTextBox.Mask = "000-00-0000";

In addition, you must ensure that the property is ResetOnSpaceset to false.

+2
source

MaskedTextBox.Mask, , .

:

myMaskedTextBox.Mask = "000-00-0000";

EDIT: , 9 , 0 .

+1

Source: https://habr.com/ru/post/1779666/


All Articles