C# DateTimePicker控件获取选中日期时间值
DateTimePicker控件用于选择日期和时间,选中的值可以通过'Value'属性获得。'Value'属性的类型为DateTime,包括日期和时间信息。例如,以下代码演示了如何获取DateTimePicker控件中选中的值:
DateTime selectedDateTime = dateTimePicker1.Value;
MessageBox.Show('选中的日期时间为:' + selectedDateTime.ToString());
上述代码中,'dateTimePicker1'为DateTimePicker控件的实例,通过'Value'属性获取选中的日期时间,并将其转换为字符串后弹出消息框显示。
原文地址: https://www.cveoy.top/t/topic/mws5 著作权归作者所有。请勿转载和采集!