窗口窗体下的DateTimePicker [英] DateTimePicker under Window Form

查看:89
本文介绍了窗口窗体下的DateTimePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#编程的Window窗口下使用DateTimePicker。



当我点击DateTimePicker时,我想今天只显示日期。



我的意思是,如果今天是2013年12月4日,当我点击DateTimePicker时,只想显示2013年12月4日起(不想在2013年12月4日之前显示)。



请给我建议怎么做?





谢谢



在同一表格中,我在DateTimePicker中选择日期后,我想更改回单击按钮(RESET)使用的原始日期。

怎么办?

请给我建议。

I use DateTimePicker under Window Form in C# programming.

When i click DateTimePicker, i want to display today onwards date only.

I mean that if today is 4 Dec 2013 , When i click DateTimePicker, only want to display 4 Dec 2013 onwards only(don't want to display before 4 Dec 2013).

Please give me advice how to do ?


Thanks

In same form, After i choose Date in DateTimePicker, i want to change back to original date used by click Button (RESET).
How to do ?
Please give me advice.

推荐答案

试试这个,

Try this,
dateTimePicker1.MinDate = DateTime.Today;

在Form_Load事件中。

in Form_Load event.


有MinDate属性。



你需要设置为今天:



dateTimeOicker1.MinDate = DateTime.Now;
There is MinDate property.

You need to set it to today:

dateTimeOicker1.MinDate = DateTime.Now;


我因为你真的应该先做你的功课,所以我们会根据你的意见回答你的问题。你需要自己学习一点。



但无论如何,这是你的解决方案:



I hesitated to reply with solution for your questions from your comments, since you really should do your homework first. You need to study a little on your own.

But anyway here it goes your solution:

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
    dateTimePicker2.MinDate = dateTimePicker1.Value;
}







但请先尝试学习一些基础知识。这样,您在尝试编写的代码的每个其他行中都不会遇到问题。祝它好运:)




But please try to learn some basics first. This way you will not face problem in every other line of the code you are trying to write. Good luck with it:)


这篇关于窗口窗体下的DateTimePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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