views:

80

answers:

2

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?

A: 

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!

Kieren Johnstone
It is WinForm and my problem is not to add a tooltip, it is to get the date that is under my mouse.
Wildhorn
OK have added the winforms tag for you :) My apologies. Hopefully this will persuade you to come over to the light side of the force (WPF)!! :)
Kieren Johnstone
If only I knew what WPF is :P
Wildhorn
+1  A: 

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.

Hans Passant
What would be the best way to do what I want then? I need a calandar control that allow me to get date with a mouseover :/
Wildhorn
Well, use a calendar control then. MonthCalendar *does* have a HitTest() method.
Hans Passant
Ah thanks. I thought that DTP was just an upgraded version of it to allow it to not take so much space.
Wildhorn