在日期选择器控制方面需要帮助吗? [英] Need help with Date Picker control?

查看:77
本文介绍了在日期选择器控制方面需要帮助吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要日期选择器控件方面的帮助.

这是我的要求,我有两个控件1)列出所有年份的组合框,以及2)组合框旁边的按钮.如果我选择一年并单击按钮,则用户只需要查看该年中的月份.用户将无法导航到下一年.

知道我们如何实现这一目标吗?请帮帮我.

前任.用户选择2009年并单击按钮,则需要显示一个日历控件,并显示从2009年1月到2009年12月的月份.用户不能导航到2010年1月.用户可以在2009年的几个月之间进行导航.

谢谢,
Mohan

Hello All,

I need help in Date picker control.

Here is my requirement, i have two controls 1) combobox with all the years listed and 2) a button next to combo box. if i select a year and click on button then user needs to see the months only in that year. user should not be able to navigate to next year.

Any idea how can we achieve this? please help me out.

ex. user selects 2009 and clicks on button then a calander control needs to be displayed with months from jan 2009 to dec 2009. user can''t be able to navigate to jan 2010. user can be able to navigate between months of 2009.

thanks,
Mohan

推荐答案

在组合框的SelectedIndexChanged事件中,设置DateTimePicker的MinDateMaxDate属性.像这样:

In the SelectedIndexChanged event of your combobox, set the MinDate and MaxDate property of your DateTimePicker. Like this:

yourDatePicker.MinDate = new DateTime(selectedYearFromDropDown, 1, 1);
yourDatePicker.MaxDate = new DateTime(selectedYearFromDropDown, 12, 31);


这篇关于在日期选择器控制方面需要帮助吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆