C# 如何使用 DateTimePicker 获取鼠标悬停的日期?
我想向 DateTimePicker 日历添加一个工具提示,根据鼠标悬停的日期显示一些信息。 有没有办法在不点击鼠标的情况下检索日期?
I want to add a tooltip to the DateTimePicker Calendar that show some informations based on the date that the mouse is over. Is there a way to retrive the date under the mouse without clicking it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本机 Windows DTP 控件相当原始。它不支持 ListView 和 TreeView 支持的 HitTest() 之类的功能。尝试从鼠标位置猜测鼠标所在位置是危险的,DTP 对控制面板区域设置中的格式覆盖很敏感。不要试图让这个工作成功。
The native Windows DTP control is quite primitive. It doesn't support anything like HitTest() as supported by ListView and TreeView. Trying to guess where the mouse is located from the mouse position is dangerous, DTP is sensitive to format overrides in the Control Panel's Region settings. Don't try to make this work.
您是在谈论日历控件吗(据我所知,WPF 中没有内置 DateTimePicker)。
请参阅下面的文章中的替换 CalendarItem 模板部分:您可以在控件中的右侧添加工具提示。
它显示了一个带有月相的日历,修改后看起来像一个计划表:非常可定制!
编辑:显然我应该说,包含源代码。
希望有帮助!
Are you talking about the Calendar control (AFAIK there is no DateTimePicker built into WPF as it stands).
See the section Replacing the CalendarItem Template in the article below: you can add your ToolTip there, right in the control.
It shows a calendar with phases of the moon, modified to look like a planner: very customisable!
Edit: Obviously I should say, there is source code included.
Hope that helps!