开发者

C# How to get the date mouseover with a DateTimePicker?

开发者 https://www.devze.com 2023-01-08 00:57 出处:网络
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 开发者_高级运维c

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 Replacing the CalendarItem Template 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!

0

精彩评论

暂无评论...
验证码 换一张
取 消