C# locale-aware MaskedTextBox mask for DateTime values
Posted
by Timothy
on Stack Overflow
See other posts from Stack Overflow
or by Timothy
Published on 2010-04-24T21:54:23Z
Indexed on
2010/04/25
0:53 UTC
Read the original article
Hit count: 712
C# locale-aware MaskedTextBox mask for DateTime values
I'm working through FXCop/Code Analysis's Globalization warnings and would like to know the proper, locale-aware way to set and get DateTime values through a MaskedTextBox.
My form has a MaskedTextBox element with its Culture property set to "en-US", and its Mask property set to "00/00/0000" (the predefined Short date format). maskedTextBox.Text = now.ToString() displays without leading-zeros as "42/42/010_", yet I would like it to be represented as "04/24/2010".
© Stack Overflow or respective owner