I'm receiving the following exception when I try to use a custom format in my DateTimePicker
:
"The string was not recognized as a valid DateTime."
I'm using the following snippet :
dtpSystemAdjustmentDate.Format = DateTimePickerFormat.Custom;
dtpSystemAdjustmentDate.CustomFormat = "mm.dd.yyyy hh:mm:ss";
I've found documentation on the Microsoft help pages : http://msdn.microsoft.com/en-us/library/aa983603%28v=vs.71%29.aspx
I Tried this snippet :
// C#
dateTimePicker1.CustomFormat = "'Today is:' hh:mm:ss dddd MMMM dd, yyyy";
I'm receiving also an exception, complaining about "Today" being a keyword that is not recognized.
I suspect something related to culture (my current Culture is fr-CH
) but I can't find a way to make it work... Any idea ?
My problem wasn't related to .Net or C#.
I tried a blank project, using the same code and it worked.
I was inheriting a subclass of Form
that is in charge of translating the Controls
within the form. Unfortunately, something is messing up the text content of my DateTimePicker
.
My previous lines were correct.