DateTimePicker 中的光标/选择位置

发布于 2024-08-11 13:51:22 字数 295 浏览 4 评论 0原文

我试图确定日期(或时间)编辑器当前选择的部分。当使用 PDA 上的导航键时,我需要提供自定义操作。特别是,我希望在按向右按钮并选择日期的最后部分(例如年份)时,焦点转到下一个控件。默认行为是循环日期部分。

我查看了 DateTimePicker 的 Win32 API 选项(链接< /a>)但它似乎不支持这一点。

有什么建议吗?

I'm trying to determine the currently selected portion of the date (or time) editor. I need to to provide custom action when the navigation keys on PDA are use. In particular i want the focus to go to the next control when pressing Right button and having the last portion of the date selected (e.g year). Default behavior is cycling through date portions.

I've looked at Win32 API options for DateTimePicker (link) but it does not seem to support this.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

安静被遗忘 2024-08-18 13:51:22

.Net cf 日期选择器是一个 PITA。

您是否尝试过捕获并覆盖

编辑:不要忘记在按“左”键时减少计数器变量!

自定义选项:我认为最好的选择是构建自己的自定义日期控件。我已经做到了。这并不太难。只需在控件中对齐三个文本框并进行一些基本验证即可。如果需要,您还可以使用选择器的日历部分。

深入了解 OpenNetCF 也是值得的。虽然我不确定是否有日期选择器的替代品,但其中有大量的课程。不过,如果您从事严肃的 CF 开发,还是值得一看的。

The .Net cf date picker is a PITA.

Have you tried trapping and overriding the KeyUp event for the "Right" button when the focus is on the date picker? You could count the number of times the "Right" key was pressed and in this way you can fake a position setting: Set a counter variable to 1 when the date picker receives focus and increment by one when you intercept the "Right" key. Test to see if it is the "Right" key and if the counter variable is a multiple of three set e.Handled = true to keep the default behavior from executing. Of course your override logic would be to set the focus to the next control.

Edit: Don't forget get to decrement the counter var on "Left" key press!

Custom Option: i think your best bet is to build your own custom date control. i've done this. It's not too difficult. It's a matter of aligning three text boxes in a control and doing some basic validation. You also still use the calendar portion of the picker if you needed to.

It's also worth it to root around in OpenNetCF. There's a ton of classes in it though i'm not sure if there will be an alternative to a date picker. Still, if you do serious CF dev, it's worth a look.

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