I've searched SO, but could't get the answer. I use a DateTimePicker on a WinForms dialog and specify a custom format: dd.MM.yyyy HH:mm:ss
. But DateTimePicker doesn't show the seconds, it always shows 00
for them. Even if I type e.g. "15" seconds, the value is correct but it's shown wrong.
What did I do wrong?
I've found out the answer by myself. If I bind the data source to the Text property of DateTimePicker, the seconds will not be shown. I have to bind to the Value property instead.
Did you set the Format property before specifying your custom format?
public void SetMyCustomFormat()
{
// Set the Format type and the CustomFormat string.
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";
}
Example cadged from the MSDN page for DateTimePicker.CustomFormat Property