锁定日期时间选择器的先前日期 [英] Lock previous date of datetimepicker

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

问题描述

我正在使用datetimepicker,我想禁用以前的日期或日期时间选择器,而将来的日期不是以前的日期..

I''m using datetimepicker i want to disable previous dates or the datetimepicker with dates future dates not previous..

推荐答案

public Form1()
{
InitializeComponent();

dateTimePicker1.MinDate = DateTime.Now.Date;

dateTimePicker1.MaxDate = DateTime.Now.AddDays(30).Date;;
}



上面的代码将为您解决问题..指定DateTimePicker的MinDate属性以限制用户选择较早的日期.

请参阅下面的链接以获取示例程序
http://doitdotnet.wordpress .com/2011/12/21/how-do-i-disable-older-dates-on-a-datetimepicker-control/ [



Above code will done the trick for you.. Specify MinDate property of DateTimePicker to restrict the user to select older dates.

Refer below link for sample program
http://doitdotnet.wordpress.com/2011/12/21/how-do-i-disable-older-dates-on-a-datetimepicker-control/[^]

Thanks


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

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