DateTimePicker Change the Color of Days

00shoe

Member
Joined
Oct 12, 2006
Messages
20
Programming Experience
3-5
Hey,

I am sorry if this question was asked before (I did search the forum and couldn’t find anything).

I am trying to find if it was possible to create a dtp that changes the color of the text of the dates that are between the dtp's min and max dates?


For example

29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13...



The text in red are the dates between the dtp min and max dates.


Thanks.
 
Yeah that what I feared :S. Could you explain to me what would have to be done, in order to achieve this? Is it as similar as getting the showtoday off the dtp?

Thanks.
 
When I say that it's not easy I mean that the control itself exposes no property or method to do it because it's not intended to be done. You would have handle the drawing of the control yourself or else use Windows API functions to get at the unmanaged underbelly of the control. It probably wouldn't take too much code, but then again it might. Either way, determining what code you need to write is likely to be a torturous task. Given that the control simply won't accept dates outside the legal range it's not really worth the effort in my opinion. If you really want to inform the user of what dates are acceptable the help topic for the DateTimePicker.DropDown event has a code example that displays a MessageBox with that information. A less intrusive method would be to use an ErrorProvider that places an icon next to the control that will display information in a ToolTip, or just put a ToolTip on the control itself. Ive seen thiord party controls that simply don't show the dates that aren't selectable, but they're built from scratch rather than inheriting the existing DTP. if you really want to do it you are in for some high-octane Googling.
 
Back
Top