Search code examples
c#winformsmaskedtextbox

Maskedtextbox Mask change depending to OS language


Hello I have created maskedtextbox in my WinForms app with mask: 0/0 AAAAA and when I do install this on PC where Czech language is set as default it converts the backslash into dot so I have 0.0 AAAAA

May I ask if is there any way to avoid this automatic change?

Thank you for your time.


Solution

  • The / character in the Mask property is the date separator. It is automatically localized, in Czech the . character is the date separator.

    You'll need to escape the character to let it know that you meant the literal. Use 0\/0 AAAAA instead. Note that added backslash.