简体   繁体   中英

C# How to get the date mouseover with a 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?

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.

Are you talking about the Calendar control (AFAIK there is no DateTimePicker built into WPF as it stands).

See the section in the article below: you can add your ToolTip there, right in the control. 部分:您可以在控件中直接在其中添加工具提示。

http://msdn.microsoft.com/en-us/magazine/dd882520.aspx

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM