Windows Develop Bookmark and Share   
 index > Windows Forms General > MonthCalendar Control BoldedDates issue
 

MonthCalendar Control BoldedDates issue

I am using .Net 2.0. Below is the issue that I am facing:

1) I have a monthcalendar control, which selects a single day.
2) I have set some of days bold using the BoldedDates property.

Issue 1) Now if I tick the year spin box in the month calendar form, it resets the control to the minimum date set for the control.
Issue 2) If the bolded dates are not set, ticking back does not refresh the control properly.
Issue 3) Is there any way for me to just disable this ticking (I reckon not, but I still would like to confirm)
Issue 4) For each change in the selection, why should DateChanged event be fired multiple times.

Let me know if more information is required.

Here is my code to bold the dates:

private void Handle_monthCalendarChild_DateChanged(object sender, DateRangeEventArgs e)
{

System.Globalization.Calendar cal = System.Globalization.CultureInfo.InvariantCulture.Calendar;
System.Diagnostics.Trace.WriteLine(e.Start.ToString(CustomFormat));
int days = cal.GetDaysInMonth(e.Start.Year, e.Start.Month);
ArrayList weekdays = new ArrayList();
for (int i = 1; i <= days; i++)
{
DateTime dt = new DateTime(e.Start.Year, e.Start.Month, i);
if ((dt.DayOfWeek == System.DayOfWeek.Saturday) ||
(dt.DayOfWeek == System.DayOfWeek.Sunday)) { }
else
weekdays.Add(dt);
}
this._monthCalendarChild.BoldedDates = (DateTime[])weekdays.ToArray(typeof(DateTime));
}
umesh_navani  Tuesday, March 17, 2009 8:01 PM

Hi,

1>

When we click year spin box, this causes the DateChanged event. So this will set the boldedDate property and repaint the control.

2>

If we set the boldedDate property, monthCalendar will be refreshed and repainted in order to show boldedDate.

3>

I think it’s difficult to implement. You’d better to make a custom monthCalendar control. (example).

4>

I try this on my side and find when I change the selection, the DateChanged event fires only one time.

If I misunderstood you, or you have other questions, please feel free to tell me.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Tuesday, March 24, 2009 3:13 AM

Hi,

1>

When we click year spin box, this causes the DateChanged event. So this will set the boldedDate property and repaint the control.

2>

If we set the boldedDate property, monthCalendar will be refreshed and repainted in order to show boldedDate.

3>

I think it’s difficult to implement. You’d better to make a custom monthCalendar control. (example).

4>

I try this on my side and find when I change the selection, the DateChanged event fires only one time.

If I misunderstood you, or you have other questions, please feel free to tell me.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Tuesday, March 24, 2009 3:13 AM

You can use google to search for other answers

Custom Search

More Threads

• Scrolling/Redrawing issue when using a FlowLayoutPanel
• Passing data
• ListView Class at design time
• Button's default property
• accessing other classes inside thread making GUI not responsive
• Experimenting with DataGridView and Webbrowser
• Binding console app (fsi.exe) to WinForm application
• NativeWindow.OnShutdown is causing a StackOverflowException
• Is anyone updating http://www.windowsforms.com/
• Closing an application