Sunday, July 8, 2012

Display a Date in a Custom Format with the Windows Forms DateTimePicker Control

dateTimePicker1.Format = DateTimePickerFormat.Custom;
// Display the date as "Mon 27 Feb 2012".
dateTimePicker1.CustomFormat = "ddd dd MMM yyyy";
// Display the date as "27 Feb 2012".
dateTimePicker1.CustomFormat = "dd MMM yyyy"; 
// Display the date as "27 Feb 2012". 
dateTimePicker1.CustomFormat = "dd MM yyyy";
// Display the date as "27 Feb 2012". 
dateTimePicker1.CustomFormat = "dd/MM/yyyy"; 

use form load or any other event;
suggest form load is mutch better than the set the property of Date Time Picker.  

1 comment:

  1. Check "dd" -> "DD" and "MM" -> "mm"
    They are case sensitive!!!!

    ReplyDelete