PDA

View Full Version : Calendar control: days of other months


snowieken
04-27-2009, 03:52 AM
If I have understood correctly, there is no direct way of telling the calendar control not to display the other dates of the currently selected month. I have found two possible work-arounds on day rendering, but they both have disadvantages. I don't know if I can explain these disadvantages correctly, so I've made an example page (http://www.woutichon.be/cal.aspx).

As you can see, the first method shows an extra row, because for some silly reason the calendar insists on showing an entire extra week of the next month. The text in the table cells has disappeared allright, but the cells still exist, so the extra row is fully shown.

The second method renders that extra row invisible, but it also renders the cells on the same row as the cells of the current month invisible, which means the dates are moved into different columns and are entirely wrong now.

Has anyone found a good workaround for this problem? What would be awesome is a combination.of the two methods: disable the text in the table cells of the months other than the currently selected one, and when there are no days of that month present in the table row, render the row invisible. I don't know if this is possible...

jleone
05-01-2009, 05:55 PM
You could set the OtherMonthDayStyle.ForeColor property equal to the same color as the DayStyle.BackColor property. In this case, you would not want the WeekendDayStyle.BackColor to be a different color or the days from the previous or next month that fall on a weekend will be displayed.

This will at least not make them "not visible" in a sense to the user, but they could still click on that area. So if you have a "Calendar1_SelectionChanged" event you will want to evaluate to see if the month selected date is equal to the current month or not if you don't want anything to occur.

snowieken
05-05-2009, 02:34 PM
This will at least not make them "not visible" in a sense to the user, but they could still click on that area. So if you have a "Calendar1_SelectionChanged" event you will want to evaluate to see if the month selected date is equal to the current month or not if you don't want anything to occur.IsSelectable can be set to False, so no problem there.

There is no way for the dates to display properly, but I have found a method I am happy enough with. Not perfect, but happy. This is definately a feature of the Calendar control I don't like - displaying overlapping days of other months is fine, but displaying an entire week of another month is just silly.

Thanks for the reply, though. :)