如何将DateTimePicker控件传递给DateTime函数 [英] how to pass DateTimePicker control into functions as DateTime
本文介绍了如何将DateTimePicker控件传递给DateTime函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将Windows窗体的DateTimePicker控件中的输入日期传递给一个函数,并将其转换为DateTime以便进行进一步的编程.
请帮助.
Sheethal
Hi,
I need to pass input date from DateTimePicker control of Windows form to a function and convert it into DateTime for further programming.
Plese help.
Sheethal
推荐答案
datetimepicker的值可以通过以下方式获取:
The value of a datetimepicker can be get by:
DateTime dateTime = dateTimePicker1.Value;
使用有什么问题:
my_DateTimePicker.Value.ToShortDateString();
?
使用值属性,然后可以将其转换为所需的格式.将其作为字符串或日期数据类型传递.如果需要,请使用Convert.ToDateTime
将其转换回日期和任何特定格式.
Whats the problem with using:
my_DateTimePicker.Value.ToShortDateString();
?
Use value property and then you can convert it into desired format. Pass it as a string or date datatype. If needed, useConvert.ToDateTime
to convert it back into a date and any specific format.
这篇关于如何将DateTimePicker控件传递给DateTime函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文