简体   繁体   English

如何在WPF DatePicker中仅选择年份(或月份)?

[英]How to select only years (or months) in WPF DatePicker?

I'm using the Datepicker that comes with visual studio 2010 but I can't find an option that lets me select only years, or only months of a given year. 我使用的是Visual Studio 2010随附的Datepicker,但找不到一个只能选择年份或给定年份的月份的选项。

(I see the wpf toolkit calendar supports this, but I'm wondering if maybe the one that comes with visual studio does as well?) (我看到wpf工具包日历支持此功能,但我想知道Visual Studio附带的功能是否也可以做到这一点?)

Duh, I should've just used the Calendar control with a popup. h,我应该将Calendar控件与一个弹出窗口一起使用。 (Calendar supports DisplayMode) (日历支持DisplayMode)

will something like this work if you coded it..??? 如果您将其编码,将可以进行类似的工作。

DateTime selectedDate = dateTimePicker1.Value;
int intMonth = DateTime.Month(selectedDate.Month);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM