Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
DateTimePickerWinForms中如何只显示月份和年份? 我想要像January 2013.
DateTimePicker
January 2013
您需要三个步骤来修改显示格式DateTimePicker:
Format
DateTimePickerFormat.Custom
CustomFormat
"MMMM yyyy"
Value
现在分配的日期将以格式显示January 2013。
您可以使用此代码,但它仅提供数字格式:
DateTime now = DateTime.Now; string s = now.ToString("MM-yy");
打印 s -> 03 13