Wednesday, May 1, 2013

C# DateTimePicker CustomFormat Month and Year

Using DateTimePicker to select month and year only.
//to configure datetimepicker for month and year.

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MMM-yyyy";
dateTimePicker1.ShowUpDown = true;

//to get value of the datetimepicker.
dateTimePicker1.Value.ToString("yyyy-MM");


Additional Reading at :
  1. MSDN DateTimePicker
  2. MSDN CustomFormat
  3. MSDN ShowUpDown

No comments:

Post a Comment