且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows窗体上datetimepicker中的当前日期

更新时间:2023-12-06 13:07:52

请检查一下。



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.