How to set Datetimepicker to Month and Year only format?
You can use DateTimerPicker.Format
property as following:
DateTimerPicker.Format = DateTimePickerFormat.Custom;
DateTimerPicker.CustomFormat = "MMMM yyyy";
DateTimerPicker.ShowUpDown = true;
Note: DateTimerPicker.ShowUpDown = true;
is for making the calendar not visible
This will give you some more options to display date with diff formats.
DateTimerPicker.Format = DateTimePickerFormat.Custom;
DateTimerPicker.CustomFormat = "MM/yyyy"; // this line gives you only the month and year.
DateTimerPicker.ShowUpDown = true;
Below are the different formats to display date alone on the date time picker control of the Windows applciation C#
DateTimerPicker.CustomFormat = "MMMM yyyy";
The above code will display the full month name and year like "August 2018"
DateTimerPicker.CustomFormat = "MMMM yyyy";
The above code will display the full month name, date and year like "08 August 2018"
DateTimerPicker.CustomFormat = "dd MM yyyy";
This line will give the date in the specified format with out forward slash "08 08 2018"
DateTimerPicker.CustomFormat = "dd/MM/yyyy";
This line will give more specific format to the date "08/08/2018"
DateTimerPicker.CustomFormat = "dd/MMM/yyyy";
This line give date in the format of "08/Aug/2018"
Use DateTimerPicker.Format
property. Check MSDN
public void SetMyCustomFormat()
{
// Set the Format type and the CustomFormat string.
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/yyyy";
}