Customize the Microsoft MonthCalendar

  • Thread starter Thread starter Martin
  • Start date Start date
M

Martin

Hi !

Someone could help me to know how to customize the MonthCalendar in
..NET 2.0 ? I would like to be able to change the color of every day in
a month...

Does Microsoft has released the code of this component ?

Thanks !

Martin
 
Martin,

MS doesn't really release code like that. Additionally, what you see in
..NET is most likely a wrapper around unmanaged code, so you wouldn't be able
to look at it through say, Reflector and see how to do what it does.

The only extensibility points that are available are the ones available
through the .NET wrapper for the control, and whatever might be offered
through unmanaged APIs. You should look at the MSDN documentation for this.

Hope this helps.
 
You can give any day, any color you like. For instance create a web page.
Drag a Calendar control on it. In the code behind do the following:

using System;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebCalendar
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : Page
{
protected Calendar Calendar1;

private void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
CalendarDay day = e.Day;
if (IsMyBirthDay(day.Date ))
{
e.Cell.BackColor = Color.Red;
}
}

private bool IsMyBirthDay(DateTime date)
{
if (date.Day == 23 && date.Month == 8)
return true;

return false;
}
}
}

This worked already in VS 2003 by the way

Cheers,
Rick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top