本文介绍了日期时间选择器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的程序中,我有两个datetimepickers.一个用于date,另一个fromdate
我想从明年开始.能帮上忙吗?


prerana



in my program i have two datetimepickers.one for todate and another fromdate
i want fromdate as next year .can any help plz


prerana

推荐答案

myDateTimePicker.Format = DateTimePickerFormat.Custom;
myDateTimePicker.CustomFormat = "yyyy";
myDateTimePicker.ShowUpDown = true;

这允许用户仅选择年份(如果需要,可以将诸如"End of"之类的文本添加到自定义格式)
然后:

This allows the user to select the year only (you can add text such as "End of " to the custom format if you wish)
Then:

DateTime endOfYear = new DateTime(myDateTimePicker.Value.Year, 12, 31, 23, 59, 59);


dateTimePicker1.value =  new DateTime(DateTime.Now.Year, 12, 31);

>


这篇关于日期时间选择器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:19
查看更多