DateTimePicker 重置日期
我正在使用具有澳大利亚日期格式设置(dd/mm/yyyy)的 DateTimePicker
问题是当用户输入月份(mm)之外的一天时,控件将该天重置为“1”。
这显然对用户来说是一个相当令人困惑的障碍 - 首先输入月份然后输入日期是不自然的[文化方面]
有没有办法禁用此验证或推迟它直到控制失去焦点时?
谢谢!
I am using DateTimePicker with Australian date formatting set (dd/mm/yyyy)
The problem is when user enters a day which is outside of the month (mm), control resets that day to "1".
This obviously is a quite confusing obstacle for user - it's not natural to enter the month first and then enter the day [culture-wise]
Is there a way to disable this validation or postpone it till say,when control loses focus?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经尝试过,但我看不到无论如何我们可以通过 DateTimePicker 的属性禁用此功能以进行微验证。
我知道当当前日期是“09/11/2009”(dd/MM/yyyy)并且用户想要通过键盘从左到右输入“31/12/2009”时您会感到沮丧。
当点击“31”时,它将恢复为“1”,因为 11 月只有 30 天。如果输入“32”,则显示“2”。
它强制用户先输入月份,然后输入日期。即朝右、左、最右方向进入。
我的建议是使用更通用的格式,例如 yyyy-MM-dd,虽然不遵循您的区域/文化格式,但仍然很容易被用户(或澳大利亚朋友)理解。
I've tried and I do not see anyway we can disable this for on micro-validation via the DateTimePicker's properties.
I know your frustration when the current date is "09/11/2009" (dd/MM/yyyy) and a user wants to enter "31/12/2009" via the keyboard from left to right.
Upon htting "31", it'll revert to "1" as Nov has only 30 days. It will show "2" if "32" is entered.
It forces the user to enter the month first followed by the day. I.e. entering in the direction of right, left, far-right.
My suggestion is use a more generic form of format like yyyy-MM-dd which though does not follow your regional/cultural format, still is easily understood by the user (or Aussie friends).
另一种选择可能是实例化编辑控件并将其覆盖在日期时间选择器的编辑之上,并使用该值来设置日期时间选择器的值。当然,在进行设置之前,您需要进行一些验证;您还需要模仿日期时间选择器的编辑字段允许您单独选择日期、月份和年份的方式。
Another option might be to instantiate an edit control and overlay it on top of the date time picker's edit, and use the value to set the date time picker's value. Of course, you'll need to do some validation before doing the setting; and you'll also want to mimic the way the date time picker's edit field allows you to select the date, month and year individually.