DateTimePicker:选择日期和时间 [英] DateTimePicker: pick both date and time

查看:56
本文介绍了DateTimePicker:选择日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 DateTimePicker (Winforms) 来选择日期和时间(在下拉列表中)?如何更改所选值的自定义显示?另外,是否可以让用户手动输入日期/时间?

Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually?

推荐答案

将格式设置为自定义,然后指定格式:

Set the Format to Custom and then specify the format:

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss";  

或者你想布置它.然后您可以直接输入日期/时间.如果您使用 MMM,则需要使用月份的数值进行输入,除非您自己为此编写一些代码(例如,5 月份的 5 个结果)

or however you want to lay it out. You could then type in directly the date/time. If you use MMM, you'll need to use the numeric value for the month for entry, unless you write some code yourself for that (e.g., 5 results in May)

不知道用于日期和时间的选择器.对我来说听起来像是自定义控件.

Don't know about the picker for date and time together. Sounds like a custom control to me.

这篇关于DateTimePicker:选择日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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