I have a monthcalendar control in my form and when I select a range, the range just whites out. I che开发者_开发技巧cked the titlebackcolor (Highlight) and titleforecolor (AliceBlue) and they are not set to white.
Anyone know what I can do to correct this?
I get the same behavior. In this screenshot, I've selected 12 through 14 Januari 2011.
The reason the rendering is incorrect has to do with Visual Styles. They are enabled by default, what normally is what you want. It enables buttons with rounded corners for instance.
If you disable VisualStyles (by removing the line Application.EnableVisualStyles()
from your Program.cs), the CalendarControl draws the range as you'd expect. However, disabling the Visual Styles also means you get outdated looking rendering for some other controls like the Button and the CheckBox control. This screenshot shows a properly rendered range selection in the MonthlyCalendar control, and also shows the outdated looking Button and CheckBox controls.
Although the MSDN reference for the MonthCalendar class doesn't mention this, the MSDN Reference on Visual Styles does mention it in its Note.
I don't know how not using Visual Styles renders on Vista or Windows 7, as I only have Windows XP at hand. But if the rendering is the same on those Operating Systems, you'd better not use the range selection of a MonthCalendar control at all.
Check TrailingForeColor
property.
Also check out details on MSDN here. You might find out anything helpful that you missed.
精彩评论