[英]How to set Datetimepicker to Month and Year only format?
如何将Datetimepicker
-Format设置为MM / YYYY?
使用DateTimerPicker.Format
属性。 检查MSDN
public void SetMyCustomFormat()
{
// Set the Format type and the CustomFormat string.
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/yyyy";
}
您可以使用DateTimerPicker.Format
属性,如下所示:
DateTimerPicker.Format = DateTimePickerFormat.Custom;
DateTimerPicker.CustomFormat = "MMMM yyyy";
DateTimerPicker.ShowUpDown = true;
注意: DateTimerPicker.ShowUpDown = true;
用于使日历不可见
这将为您提供更多选项,以显示diff格式的日期。
DateTimerPicker.Format = DateTimePickerFormat.Custom;
DateTimerPicker.CustomFormat = "MM/yyyy"; // this line gives you only the month and year.
DateTimerPicker.ShowUpDown = true;
以下是在Windows应用程序C#的日期时间选择器控件上单独显示日期的不同格式
DateTimerPicker.CustomFormat = "MMMM yyyy";
上面的代码将显示完整的月份名称和年份,如“2018年8月”
DateTimerPicker.CustomFormat = "MMMM yyyy";
上面的代码将显示完整的月份名称,日期和年份,如“2018年8月8日”
DateTimerPicker.CustomFormat = "dd MM yyyy";
该行将以指定格式给出日期,而不包括正斜杠“08 08 2018”
DateTimerPicker.CustomFormat = "dd/MM/yyyy";
此行将为日期“08/08/2018”提供更具体的格式
DateTimerPicker.CustomFormat = "dd/MMM/yyyy";
此行的格式为“08 / Aug / 2018”
这条线对我有用
DateTimePicker1.Value.ToString("MMMM dd yyyy")
产量:2019年8月
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.