DateTimePicker 中的光标/选择位置
我试图确定日期(或时间)编辑器当前选择的部分。当使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.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.