DateTimePicker 重置日期

发布于 2024-08-10 17:15:08 字数 194 浏览 6 评论 0原文

我正在使用具有澳大利亚日期格式设置(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪是无色的血 2024-08-17 17:15:08

我已经尝试过,但我看不到无论如何我们可以通过 DateTimePicker 的属性禁用此功能以进行微验证。

我知道当当前日期是“09/11/2009”(dd/MM/yyyy)并且用户想要通过键盘从左到右输入“31/12/2009”时您会感到沮丧。

DateTimePicker 1

当点击“31”时,它将恢复为“1”,因为 11 月只有 30 天。如果输入“32”,则显示“2”。

DateTimePicker2

它强制用户先输入月份,然后输入日期。即朝右、左、最右方向进入。

我的建议是使用更通用的格式,例如 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.

DateTimePicker 1

Upon htting "31", it'll revert to "1" as Nov has only 30 days. It will show "2" if "32" is entered.

DateTimePicker2

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).

无力看清 2024-08-17 17:15:08

另一种选择可能是实例化编辑控件并将其覆盖在日期时间选择器的编辑之上,并使用该值来设置日期时间选择器的值。当然,在进行设置之前,您需要进行一些验证;您还需要模仿日期时间选择器的编辑字段允许您单独选择日期、月份和年份的方式。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文