Windows窗体上datetimepicker中的当前日期 [英] current date in datetimepicker on windows form

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

问题描述

Hi all....

Could you plz let me know that hw you get the current date in the datetimepicker? ( I need coding)





i设计了短格式属性,但没有工作



i have set short format property on design , but not working

推荐答案

请检查一下。



Please check this.

dateTimePicker1.Value = System.DateTime.Now;


您可以将格式设置为自定义,然后您就可以将其作为日期格式。



您可以访问从代码中.Text属性的日期时间选择器中选择的当前日期。
You may set the format to custom then you will be able to get it as date format.

you can access the current date selected from the date time picker from .Text property in code.


我在我的系统中测试了它。

将格式设置为''短/自定义''仅适用于在控件中显示日期。

如果您想使用当前日期或其中的选定日期,那么您可以使用像这样的文本控件属性:



I tested it in my System.
Setting Format to ''Short/Custom'' works fine for showing only Date in the Control.
And if u want to use the current date or selected date from it, then you can use the ''Text'' property of control like this:

label1.Text = dateTimePicker1.Text;





它和我一起工作正常。

退房。



It''s working fine with me.
Check out.


这篇关于Windows窗体上datetimepicker中的当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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