Month Calendar update solution and SelectionRange is rubbish
hi,
the solution is to tell the control to refresh itself, this is not done automatically as i guess it would flicker.
try:
monthCalendarName.UpdateBoldedDates();
another problem with calendar is detailed here you may come across it:
my .net remoting application client winform needs to select and highlight
dates, to get to these dates once highlighted we can use SelectionRange
but we cannot simply do a monthCalendar.AddBoldedDate(monthCalendar.SelectionRange)
which would be great, it seems obfuscated and less than useful considering the implementation
it could have been (as above.)
Here was my solution, its commented so i wont repleat myself.
Hope this helps all confused by the SelectionRange !
c.
//get start of selection
DateTime startDate = monthCalendarMain.SelectionStart.Date;
//get end of selection
DateTime endDate = monthCalendarMain.SelectionEnd.Date;
//timespan calculated from end date minus start date
TimeSpan timeSpan = endDate.Subtract(startDate);
//create a dateTime array to hold our new dates for bolding
DateTime [] selectedDates = new DateTime [timeSpan.Days + 1];
//loop for how ever many dates there are in calendar selection
for (int index = 0; index < selectedDates.Length; index++)
{
//for each one set it to bold, this preserves the existing selections.
monthCalendarMain.AddBoldedDate(startDate.AddDays(Convert.ToDouble(index)));
}
//show user the changes
monthCalendarMain.UpdateBoldedDates();
--------------------------------
From: craig soens-hughes